Skip to content
Snippets Groups Projects
Unverified Commit 246aefee authored by ordian's avatar ordian Committed by GitHub
Browse files

Merge pull request #18 from paritytech/na-bump-rand

[Cargo.toml] update rand to 0.7 (breaking change)
parents 72c93ab5 b8c8f7a4
No related merge requests found
Pipeline #54123 passed with stages
in 1 minute and 33 seconds
......@@ -27,9 +27,9 @@ dev = ["clippy"]
[dependencies]
arrayvec = "0.4"
clippy = {version = "0.0", optional = true}
rand = "0.6"
clippy = { version = "0.0", optional = true }
rand = "0.7"
[dev-dependencies]
hex-literal = "0.2"
rand_core = "0.4.2"
rand_core = "0.5.1"
......@@ -16,7 +16,7 @@
//! # Public and secret keys
use arrayvec::ArrayVec;
use rand::Rng;
use rand::RngCore;
use super::{Secp256k1, ContextFlag};
use super::Error::{self, IncapableContext, InvalidPublicKey, InvalidSecretKey};
......@@ -64,7 +64,7 @@ pub const MINUS_ONE_KEY: SecretKey = SecretKey([0xff, 0xff, 0xff, 0xff, 0xff, 0x
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
pub struct PublicKey(ffi::PublicKey);
fn random_32_bytes<R: Rng>(rng: &mut R) -> [u8; 32] {
fn random_32_bytes<R: RngCore>(rng: &mut R) -> [u8; 32] {
let mut ret = [0u8; 32];
rng.fill_bytes(&mut ret);
ret
......@@ -73,7 +73,7 @@ fn random_32_bytes<R: Rng>(rng: &mut R) -> [u8; 32] {
impl SecretKey {
/// Creates a new random secret key
#[inline]
pub fn new<R: Rng>(secp: &Secp256k1, rng: &mut R) -> SecretKey {
pub fn new<R: RngCore>(secp: &Secp256k1, rng: &mut R) -> SecretKey {
let mut data = random_32_bytes(rng);
unsafe {
while ffi::secp256k1_ec_seckey_verify(secp.ctx, data.as_ptr()) == 0 {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment