Merge pull request #104 from alekseysidorov/fix_rand

Fix `Rand` trait bounds.
This commit is contained in:
Andrew Poelstra 2019-05-01 01:47:43 +00:00 committed by GitHub
commit 90faf434c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -32,7 +32,7 @@ fuzztarget = []
[dev-dependencies] [dev-dependencies]
rand = "0.6" rand = "0.6"
rand_core = "0.3" rand_core = "0.4"
serde_test = "1.0" serde_test = "1.0"
[dependencies.rand] [dependencies.rand]

View File

@ -90,7 +90,7 @@ impl str::FromStr for PublicKey {
} }
#[cfg(any(test, feature = "rand"))] #[cfg(any(test, feature = "rand"))]
fn random_32_bytes<R: Rng>(rng: &mut R) -> [u8; 32] { fn random_32_bytes<R: Rng + ?Sized>(rng: &mut R) -> [u8; 32] {
let mut ret = [0u8; 32]; let mut ret = [0u8; 32];
rng.fill_bytes(&mut ret); rng.fill_bytes(&mut ret);
ret ret
@ -100,7 +100,7 @@ impl SecretKey {
/// Creates a new random secret key. Requires compilation with the "rand" feature. /// Creates a new random secret key. Requires compilation with the "rand" feature.
#[inline] #[inline]
#[cfg(any(test, feature = "rand"))] #[cfg(any(test, feature = "rand"))]
pub fn new<R: Rng>(rng: &mut R) -> SecretKey { pub fn new<R: Rng + ?Sized>(rng: &mut R) -> SecretKey {
let mut data = random_32_bytes(rng); let mut data = random_32_bytes(rng);
unsafe { unsafe {
while ffi::secp256k1_ec_seckey_verify( while ffi::secp256k1_ec_seckey_verify(

View File

@ -651,7 +651,7 @@ impl<C> Secp256k1<C> {
/// see comment in libsecp256k1 commit d2275795f by Gregory Maxwell. Requires /// see comment in libsecp256k1 commit d2275795f by Gregory Maxwell. Requires
/// compilation with "rand" feature. /// compilation with "rand" feature.
#[cfg(any(test, feature = "rand"))] #[cfg(any(test, feature = "rand"))]
pub fn randomize<R: Rng>(&mut self, rng: &mut R) { pub fn randomize<R: Rng + ?Sized>(&mut self, rng: &mut R) {
let mut seed = [0; 32]; let mut seed = [0; 32];
rng.fill_bytes(&mut seed); rng.fill_bytes(&mut seed);
unsafe { unsafe {
@ -720,7 +720,7 @@ impl<C: Signing> Secp256k1<C> {
/// with the "rand" feature. /// with the "rand" feature.
#[inline] #[inline]
#[cfg(any(test, feature = "rand"))] #[cfg(any(test, feature = "rand"))]
pub fn generate_keypair<R: Rng>(&self, rng: &mut R) pub fn generate_keypair<R: Rng + ?Sized>(&self, rng: &mut R)
-> (key::SecretKey, key::PublicKey) { -> (key::SecretKey, key::PublicKey) {
let sk = key::SecretKey::new(rng); let sk = key::SecretKey::new(rng);
let pk = key::PublicKey::from_secret_key(self, &sk); let pk = key::PublicKey::from_secret_key(self, &sk);