-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
elliptic-curve: add Generate
trait
#220
Conversation
|
05d2013
to
1a024bb
Compare
elliptic-curve/src/lib.rs
Outdated
#[cfg(feature = "rand_core")] | ||
pub trait Generate { | ||
/// Generate a random element of this type using the provided [`CryptoRng`] | ||
fn generate(rng: &mut (impl CryptoRng + RngCore)) -> Self; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RngCore
is implemented for mutable RNG references, so we can use rng: impl CryptoRng + RngCore
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh, nice
Trait for randomly generating types using a `rand_core::CryptoRng`. Potentially useful in trait bounds that need to generate e.g. `Scalar` types.
1a024bb
to
88fd50e
Compare
Impls the new trait for random generation added in RustCrypto/traits#220. This can potentially be used to completely replace the `GenerateSecretKey` trait, since that can now be made a conditionally impl'd inherent method on `SecretKey` with where bounds on `Scalar: Generate`.
Impls the new trait for random generation added in RustCrypto/traits#220. This can potentially be used to completely replace the `GenerateSecretKey` trait, since that can now be made a conditionally impl'd inherent method on `SecretKey` with where bounds on `Scalar: Generate`.
Impls the new trait for random generation added in RustCrypto/traits#220. This can potentially be used to completely replace the `GenerateSecretKey` trait, since that can now be made a conditionally impl'd inherent method on `SecretKey` with where bounds on `Scalar: Generate`.
This enables performing a much more exhaustive set of tests for `no_std` targets, which as of RustCrypto#215 all crates in this repo are fully capable.
Trait for randomly generating types using a
rand_core::CryptoRng
.Potentially useful in trait bounds that need to generate e.g.
Scalar
types.