From 49a53e45f494d4a34b6848513bbb2117debf44a6 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Mon, 27 Jul 2020 16:46:00 -0700 Subject: [PATCH] elliptic-curve: impl Generate for SecretKey This method fits the existing `Generate` trait. This allows bounds to simply specify `where SecretKey: Generate` to write code that needs to handle generic generation of secret keys, as opposed to trying to encode the full bounds for the impl. --- elliptic-curve/src/secret_key.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elliptic-curve/src/secret_key.rs b/elliptic-curve/src/secret_key.rs index 81c3ffeff..31de82fd9 100644 --- a/elliptic-curve/src/secret_key.rs +++ b/elliptic-curve/src/secret_key.rs @@ -69,13 +69,13 @@ impl Debug for SecretKey { #[cfg(feature = "rand_core")] #[cfg_attr(docsrs, doc(cfg(feature = "rand_core")))] -impl SecretKey +impl Generate for SecretKey where C: Curve + Arithmetic, C::Scalar: Generate + Into>, { /// Generate a new [`SecretKey`] - pub fn generate(rng: impl CryptoRng + RngCore) -> Self { + fn generate(rng: impl CryptoRng + RngCore) -> Self { Self { scalar: C::Scalar::generate(rng).into(), }