Migrate remaining crates to rand_core 0.4

This commit is contained in:
Jack Grigg 2019-07-13 01:54:47 -04:00
parent 8f7adec0d9
commit b0913afdd7
No known key found for this signature in database
GPG Key ID: 9E8255172BBF9898
9 changed files with 28 additions and 31 deletions

21
Cargo.lock generated
View File

@ -315,7 +315,8 @@ dependencies = [
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)",
"pairing 0.14.2", "pairing 0.14.2",
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"sapling-crypto 0.0.1", "sapling-crypto 0.0.1",
"zcash_primitives 0.0.0", "zcash_primitives 0.0.0",
"zcash_proofs 0.0.0", "zcash_proofs 0.0.0",
@ -406,18 +407,6 @@ dependencies = [
"proc-macro2 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "rand"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.6.5" version = "0.6.5"
@ -603,7 +592,8 @@ version = "0.0.0"
dependencies = [ dependencies = [
"bech32 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "bech32 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pairing 0.14.2", "pairing 0.14.2",
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"sapling-crypto 0.0.1", "sapling-crypto 0.0.1",
"zcash_primitives 0.0.0", "zcash_primitives 0.0.0",
] ]
@ -636,7 +626,7 @@ dependencies = [
"byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ff 0.4.0", "ff 0.4.0",
"pairing 0.14.2", "pairing 0.14.2",
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"sapling-crypto 0.0.1", "sapling-crypto 0.0.1",
"zcash_primitives 0.0.0", "zcash_primitives 0.0.0",
] ]
@ -689,7 +679,6 @@ dependencies = [
"checksum proc-macro-hack-impl 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d5cb6f960ad471404618e9817c0e5d10b1ae74cfdf01fab89ea0641fe7fb2892" "checksum proc-macro-hack-impl 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d5cb6f960ad471404618e9817c0e5d10b1ae74cfdf01fab89ea0641fe7fb2892"
"checksum proc-macro2 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)" = "b331c6ad3411474cd55540398dc7ad89fc41488e64ec71fdecc9c9b86de96fb0" "checksum proc-macro2 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)" = "b331c6ad3411474cd55540398dc7ad89fc41488e64ec71fdecc9c9b86de96fb0"
"checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5" "checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5"
"checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9"
"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
"checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef"
"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"

View File

@ -22,7 +22,8 @@ libc = "0.2"
pairing = { path = "../pairing" } pairing = { path = "../pairing" }
lazy_static = "1" lazy_static = "1"
byteorder = "1" byteorder = "1"
rand = "0.5" rand_core = "0.4"
rand_os = "0.1"
sapling-crypto = { path = "../sapling-crypto" } sapling-crypto = { path = "../sapling-crypto" }
zcash_primitives = { path = "../zcash_primitives" } zcash_primitives = { path = "../zcash_primitives" }
zcash_proofs = { path = "../zcash_proofs" } zcash_proofs = { path = "../zcash_proofs" }

View File

@ -5,7 +5,8 @@ extern crate byteorder;
extern crate ff; extern crate ff;
extern crate libc; extern crate libc;
extern crate pairing; extern crate pairing;
extern crate rand; extern crate rand_core;
extern crate rand_os;
extern crate sapling_crypto; extern crate sapling_crypto;
extern crate zcash_primitives; extern crate zcash_primitives;
extern crate zcash_proofs; extern crate zcash_proofs;
@ -37,7 +38,8 @@ use blake2s_simd::Params as Blake2sParams;
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use rand::{OsRng, Rng}; use rand_core::RngCore;
use rand_os::OsRng;
use std::io::BufReader; use std::io::BufReader;
use libc::{c_char, c_uchar, int64_t, size_t, uint32_t, uint64_t}; use libc::{c_char, c_uchar, int64_t, size_t, uint32_t, uint64_t};
@ -388,9 +390,7 @@ pub extern "system" fn librustzcash_sapling_generate_r(result: *mut [c_uchar; 32
// create random 64 byte buffer // create random 64 byte buffer
let mut rng = OsRng::new().expect("should be able to construct RNG"); let mut rng = OsRng::new().expect("should be able to construct RNG");
let mut buffer = [0u8; 64]; let mut buffer = [0u8; 64];
for i in 0..buffer.len() { rng.fill_bytes(&mut buffer);
buffer[i] = rng.gen();
}
// reduce to uniform value // reduce to uniform value
let r = <Bls12 as JubjubEngine>::Fs::to_uniform(&buffer[..]); let r = <Bls12 as JubjubEngine>::Fs::to_uniform(&buffer[..]);

View File

@ -1,6 +1,7 @@
use ff::{PrimeField, PrimeFieldRepr}; use ff::{PrimeField, PrimeFieldRepr};
use pairing::bls12_381::Bls12; use pairing::bls12_381::Bls12;
use rand::{OsRng, Rng}; use rand_core::RngCore;
use rand_os::OsRng;
use sapling_crypto::jubjub::{edwards, JubjubBls12}; use sapling_crypto::jubjub::{edwards, JubjubBls12};
use sapling_crypto::primitives::{Diversifier, ViewingKey}; use sapling_crypto::primitives::{Diversifier, ViewingKey};
@ -22,7 +23,9 @@ fn test_key_agreement() {
// Create a random address with the viewing key // Create a random address with the viewing key
let addr = loop { let addr = loop {
match vk.into_payment_address(Diversifier(rng.gen()), &params) { let mut d = [0; 11];
rng.fill_bytes(&mut d);
match vk.into_payment_address(Diversifier(d), &params) {
Some(a) => break a, Some(a) => break a,
None => {} None => {}
} }

View File

@ -13,4 +13,5 @@ sapling-crypto = { path = "../sapling-crypto" }
zcash_primitives = { path = "../zcash_primitives" } zcash_primitives = { path = "../zcash_primitives" }
[dev-dependencies] [dev-dependencies]
rand = "0.5" rand_core = "0.4"
rand_xorshift = "0.1"

View File

@ -101,7 +101,8 @@ pub fn decode_extended_full_viewing_key(
/// ///
/// ``` /// ```
/// use pairing::bls12_381::Bls12; /// use pairing::bls12_381::Bls12;
/// use rand::{SeedableRng, XorShiftRng}; /// use rand_core::SeedableRng;
/// use rand_xorshift::XorShiftRng;
/// use sapling_crypto::{ /// use sapling_crypto::{
/// jubjub::edwards, /// jubjub::edwards,
/// primitives::{Diversifier, PaymentAddress}, /// primitives::{Diversifier, PaymentAddress},
@ -140,7 +141,8 @@ pub fn encode_payment_address(hrp: &str, addr: &PaymentAddress<Bls12>) -> String
/// ///
/// ``` /// ```
/// use pairing::bls12_381::Bls12; /// use pairing::bls12_381::Bls12;
/// use rand::{SeedableRng, XorShiftRng}; /// use rand_core::SeedableRng;
/// use rand_xorshift::XorShiftRng;
/// use sapling_crypto::{ /// use sapling_crypto::{
/// jubjub::edwards, /// jubjub::edwards,
/// primitives::{Diversifier, PaymentAddress}, /// primitives::{Diversifier, PaymentAddress},
@ -188,7 +190,8 @@ pub fn decode_payment_address(hrp: &str, s: &str) -> Result<Option<PaymentAddres
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use pairing::bls12_381::Bls12; use pairing::bls12_381::Bls12;
use rand::{SeedableRng, XorShiftRng}; use rand_core::SeedableRng;
use rand_xorshift::XorShiftRng;
use sapling_crypto::{ use sapling_crypto::{
jubjub::edwards, jubjub::edwards,
primitives::{Diversifier, PaymentAddress}, primitives::{Diversifier, PaymentAddress},

View File

@ -11,6 +11,6 @@ blake2b_simd = "0.5"
byteorder = "1" byteorder = "1"
ff = { path = "../ff" } ff = { path = "../ff" }
pairing = { path = "../pairing" } pairing = { path = "../pairing" }
rand = "0.5" rand_os = "0.1"
sapling-crypto = { path = "../sapling-crypto" } sapling-crypto = { path = "../sapling-crypto" }
zcash_primitives = { path = "../zcash_primitives" } zcash_primitives = { path = "../zcash_primitives" }

View File

@ -3,7 +3,7 @@ extern crate blake2b_simd;
extern crate byteorder; extern crate byteorder;
extern crate ff; extern crate ff;
extern crate pairing; extern crate pairing;
extern crate rand; extern crate rand_os;
extern crate sapling_crypto; extern crate sapling_crypto;
extern crate zcash_primitives; extern crate zcash_primitives;

View File

@ -3,7 +3,7 @@ use bellman::groth16::{
}; };
use ff::Field; use ff::Field;
use pairing::bls12_381::{Bls12, Fr}; use pairing::bls12_381::{Bls12, Fr};
use rand::OsRng; use rand_os::OsRng;
use sapling_crypto::{ use sapling_crypto::{
circuit::{ circuit::{
multipack, multipack,