diff --git a/Cargo.lock b/Cargo.lock index d4aee36..4c36e99 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -534,7 +534,8 @@ dependencies = [ "ff 0.4.0", "hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/sapling-crypto/Cargo.toml b/sapling-crypto/Cargo.toml index 34e91eb..da28615 100644 --- a/sapling-crypto/Cargo.toml +++ b/sapling-crypto/Cargo.toml @@ -17,10 +17,11 @@ bellman = { path = "../bellman" } blake2b_simd = "0.5" blake2s_simd = "0.5" ff = { path = "../ff" } -rand = "0.5" +rand_core = "0.4" digest = "0.7" byteorder = "1" [dev-dependencies] hex-literal = "0.1" +rand_xorshift = "0.1" sha2 = "0.8" diff --git a/sapling-crypto/examples/bench.rs b/sapling-crypto/examples/bench.rs index 9b4c0ae..e9ffc13 100644 --- a/sapling-crypto/examples/bench.rs +++ b/sapling-crypto/examples/bench.rs @@ -1,8 +1,9 @@ extern crate ff; extern crate sapling_crypto; extern crate bellman; -extern crate rand; extern crate pairing; +extern crate rand_core; +extern crate rand_xorshift; use ff::Field; use std::time::{Duration, Instant}; @@ -20,7 +21,8 @@ use sapling_crypto::primitives::{ ValueCommitment }; use bellman::groth16::*; -use rand::{XorShiftRng, SeedableRng, Rng, RngCore}; +use rand_core::{RngCore, SeedableRng}; +use rand_xorshift::XorShiftRng; use pairing::bls12_381::{Bls12, Fr}; const TREE_DEPTH: usize = 32; @@ -86,7 +88,7 @@ fn main() { } let commitment_randomness = fs::Fs::random(rng); - let auth_path = vec![Some((Fr::random(rng), rng.gen())); TREE_DEPTH]; + let auth_path = vec![Some((Fr::random(rng), rng.next_u32() % 2 != 0)); TREE_DEPTH]; let ar = fs::Fs::random(rng); let anchor = Fr::random(rng); diff --git a/sapling-crypto/src/circuit/blake2s.rs b/sapling-crypto/src/circuit/blake2s.rs index e6748ba..8627dc0 100644 --- a/sapling-crypto/src/circuit/blake2s.rs +++ b/sapling-crypto/src/circuit/blake2s.rs @@ -321,8 +321,10 @@ pub fn blake2s>( #[cfg(test)] mod test { use blake2s_simd::Params as Blake2sParams; - use rand::{XorShiftRng, SeedableRng, Rng}; use pairing::bls12_381::{Bls12}; + use rand_core::{RngCore, SeedableRng}; + use rand_xorshift::XorShiftRng; + use ::circuit::boolean::{Boolean, AllocatedBit}; use ::circuit::test::TestConstraintSystem; use super::blake2s; @@ -371,7 +373,7 @@ mod test { 0xe5, ]); let input_bits: Vec<_> = (0..512) - .map(|_| Boolean::constant(rng.gen())) + .map(|_| Boolean::constant(rng.next_u32() % 2 != 0)) .chain((0..512) .map(|i| AllocatedBit::alloc(cs.namespace(|| format!("input bit {}", i)), Some(true)).unwrap().into())) .collect(); @@ -387,7 +389,7 @@ mod test { 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, 0xe5, ]); - let input_bits: Vec<_> = (0..512).map(|_| Boolean::constant(rng.gen())).collect(); + let input_bits: Vec<_> = (0..512).map(|_| Boolean::constant(rng.next_u32() % 2 != 0)).collect(); blake2s(&mut cs, &input_bits, b"12345678").unwrap(); assert_eq!(cs.num_constraints(), 0); } @@ -403,7 +405,7 @@ mod test { { let mut h = Blake2sParams::new().hash_length(32).personal(b"12345678").to_state(); - let data: Vec = (0..input_len).map(|_| rng.gen()).collect(); + let data: Vec = (0..input_len).map(|_| rng.next_u32() as u8).collect(); h.update(&data); diff --git a/sapling-crypto/src/circuit/ecc.rs b/sapling-crypto/src/circuit/ecc.rs index 3fc9713..9b4dbbc 100644 --- a/sapling-crypto/src/circuit/ecc.rs +++ b/sapling-crypto/src/circuit/ecc.rs @@ -748,9 +748,11 @@ impl MontgomeryPoint { #[cfg(test)] mod test { use bellman::{ConstraintSystem}; - use rand::{XorShiftRng, SeedableRng, Rng}; use ff::{BitIterator, Field, PrimeField}; use pairing::bls12_381::{Bls12, Fr}; + use rand_core::{RngCore, SeedableRng}; + use rand_xorshift::XorShiftRng; + use ::circuit::test::*; use ::jubjub::{ montgomery, @@ -1001,10 +1003,10 @@ mod test { y: num_y0 }; - let mut should_we_select = rng.gen(); + let mut should_we_select = rng.next_u32() % 2 != 0; // Conditionally allocate - let mut b = if rng.gen() { + let mut b = if rng.next_u32() % 2 != 0 { Boolean::from(AllocatedBit::alloc( cs.namespace(|| "condition"), Some(should_we_select) @@ -1014,7 +1016,7 @@ mod test { }; // Conditionally negate - if rng.gen() { + if rng.next_u32() % 2 != 0 { b = b.not(); should_we_select = !should_we_select; } @@ -1163,7 +1165,7 @@ mod test { for _ in 0..100 { let p1 = loop { let x = Fr::random(rng); - let s: bool = rng.gen(); + let s: bool = rng.next_u32() % 2 != 0; if let Some(p) = montgomery::Point::::get_for_x(x, s, params) { break p; @@ -1172,7 +1174,7 @@ mod test { let p2 = loop { let x = Fr::random(rng); - let s: bool = rng.gen(); + let s: bool = rng.next_u32() % 2 != 0; if let Some(p) = montgomery::Point::::get_for_x(x, s, params) { break p; diff --git a/sapling-crypto/src/circuit/lookup.rs b/sapling-crypto/src/circuit/lookup.rs index 4b6e13b..d57f17c 100644 --- a/sapling-crypto/src/circuit/lookup.rs +++ b/sapling-crypto/src/circuit/lookup.rs @@ -196,11 +196,12 @@ pub fn lookup3_xy_with_conditional_negation( #[cfg(test)] mod test { - use rand::{SeedableRng, Rng, XorShiftRng}; use super::*; use ::circuit::test::*; use ::circuit::boolean::{Boolean, AllocatedBit}; use pairing::bls12_381::{Bls12, Fr}; + use rand_core::{RngCore, SeedableRng}; + use rand_xorshift::XorShiftRng; #[test] fn test_lookup3_xy() { @@ -212,17 +213,17 @@ mod test { for _ in 0..100 { let mut cs = TestConstraintSystem::::new(); - let a_val = rng.gen(); + let a_val = rng.next_u32() % 2 != 0; let a = Boolean::from( AllocatedBit::alloc(cs.namespace(|| "a"), Some(a_val)).unwrap() ); - let b_val = rng.gen(); + let b_val = rng.next_u32() % 2 != 0; let b = Boolean::from( AllocatedBit::alloc(cs.namespace(|| "b"), Some(b_val)).unwrap() ); - let c_val = rng.gen(); + let c_val = rng.next_u32() % 2 != 0; let c = Boolean::from( AllocatedBit::alloc(cs.namespace(|| "c"), Some(c_val)).unwrap() ); @@ -255,17 +256,17 @@ mod test { for _ in 0..100 { let mut cs = TestConstraintSystem::::new(); - let a_val = rng.gen(); + let a_val = rng.next_u32() % 2 != 0; let a = Boolean::from( AllocatedBit::alloc(cs.namespace(|| "a"), Some(a_val)).unwrap() ); - let b_val = rng.gen(); + let b_val = rng.next_u32() % 2 != 0; let b = Boolean::from( AllocatedBit::alloc(cs.namespace(|| "b"), Some(b_val)).unwrap() ); - let c_val = rng.gen(); + let c_val = rng.next_u32() % 2 != 0; let c = Boolean::from( AllocatedBit::alloc(cs.namespace(|| "c"), Some(c_val)).unwrap() ); diff --git a/sapling-crypto/src/circuit/multipack.rs b/sapling-crypto/src/circuit/multipack.rs index fd7cbfb..fdecd34 100644 --- a/sapling-crypto/src/circuit/multipack.rs +++ b/sapling-crypto/src/circuit/multipack.rs @@ -80,9 +80,11 @@ pub fn compute_multipacking( #[test] fn test_multipacking() { - use rand::{SeedableRng, Rng, XorShiftRng}; use bellman::{ConstraintSystem}; use pairing::bls12_381::{Bls12}; + use rand_core::{RngCore, SeedableRng}; + use rand_xorshift::XorShiftRng; + use ::circuit::test::*; use super::boolean::{AllocatedBit, Boolean}; @@ -94,7 +96,7 @@ fn test_multipacking() { for num_bits in 0..1500 { let mut cs = TestConstraintSystem::::new(); - let bits: Vec = (0..num_bits).map(|_| rng.gen()).collect(); + let bits: Vec = (0..num_bits).map(|_| rng.next_u32() % 2 != 0).collect(); let circuit_bits = bits.iter().enumerate() .map(|(i, &b)| { diff --git a/sapling-crypto/src/circuit/num.rs b/sapling-crypto/src/circuit/num.rs index 7201356..1cdfe22 100644 --- a/sapling-crypto/src/circuit/num.rs +++ b/sapling-crypto/src/circuit/num.rs @@ -455,10 +455,12 @@ impl Num { #[cfg(test)] mod test { - use rand::{SeedableRng, XorShiftRng}; use bellman::{ConstraintSystem}; use ff::{BitIterator, Field, PrimeField}; use pairing::bls12_381::{Bls12, Fr}; + use rand_core::SeedableRng; + use rand_xorshift::XorShiftRng; + use ::circuit::test::*; use super::{AllocatedNum, Boolean}; diff --git a/sapling-crypto/src/circuit/pedersen_hash.rs b/sapling-crypto/src/circuit/pedersen_hash.rs index f26b98e..dd000d3 100644 --- a/sapling-crypto/src/circuit/pedersen_hash.rs +++ b/sapling-crypto/src/circuit/pedersen_hash.rs @@ -112,12 +112,13 @@ pub fn pedersen_hash( #[cfg(test)] mod test { - use rand::{SeedableRng, Rng, XorShiftRng}; use super::*; use ::circuit::test::*; use ::circuit::boolean::{Boolean, AllocatedBit}; use ff::PrimeField; use pairing::bls12_381::{Bls12, Fr}; + use rand_core::{RngCore, SeedableRng}; + use rand_xorshift::XorShiftRng; #[test] fn test_pedersen_hash_constraints() { @@ -128,7 +129,7 @@ mod test { let params = &JubjubBls12::new(); let mut cs = TestConstraintSystem::::new(); - let input: Vec = (0..(Fr::NUM_BITS * 2)).map(|_| rng.gen()).collect(); + let input: Vec = (0..(Fr::NUM_BITS * 2)).map(|_| rng.next_u32() % 2 != 0).collect(); let input_bools: Vec = input.iter().enumerate().map(|(i, b)| { Boolean::from( @@ -157,7 +158,7 @@ mod test { for length in 0..751 { for _ in 0..5 { - let mut input: Vec = (0..length).map(|_| rng.gen()).collect(); + let mut input: Vec = (0..length).map(|_| rng.next_u32() % 2 != 0).collect(); let mut cs = TestConstraintSystem::::new(); diff --git a/sapling-crypto/src/circuit/sapling/mod.rs b/sapling-crypto/src/circuit/sapling/mod.rs index 2c4d566..469ab2e 100644 --- a/sapling-crypto/src/circuit/sapling/mod.rs +++ b/sapling-crypto/src/circuit/sapling/mod.rs @@ -600,7 +600,9 @@ impl<'a, E: JubjubEngine> Circuit for Output<'a, E> { fn test_input_circuit_with_bls12_381() { use ff::{BitIterator, Field}; use pairing::bls12_381::*; - use rand::{SeedableRng, Rng, RngCore, XorShiftRng}; + use rand_core::{RngCore, SeedableRng}; + use rand_xorshift::XorShiftRng; + use ::circuit::test::*; use jubjub::{JubjubBls12, fs, edwards}; @@ -614,7 +616,7 @@ fn test_input_circuit_with_bls12_381() { for _ in 0..10 { let value_commitment = ValueCommitment { - value: rng.gen(), + value: rng.next_u64(), randomness: fs::Fs::random(rng), }; @@ -649,7 +651,7 @@ fn test_input_circuit_with_bls12_381() { let g_d = payment_address.diversifier.g_d(params).unwrap(); let commitment_randomness = fs::Fs::random(rng); - let auth_path = vec![Some((Fr::random(rng), rng.gen())); tree_depth]; + let auth_path = vec![Some((Fr::random(rng), rng.next_u32() % 2 != 0)); tree_depth]; let ar = fs::Fs::random(rng); { @@ -739,7 +741,8 @@ fn test_input_circuit_with_bls12_381() { fn test_output_circuit_with_bls12_381() { use ff::Field; use pairing::bls12_381::*; - use rand::{SeedableRng, Rng, RngCore, XorShiftRng}; + use rand_core::{RngCore, SeedableRng}; + use rand_xorshift::XorShiftRng; use ::circuit::test::*; use jubjub::{JubjubBls12, fs, edwards}; @@ -751,7 +754,7 @@ fn test_output_circuit_with_bls12_381() { for _ in 0..100 { let value_commitment = ValueCommitment { - value: rng.gen(), + value: rng.next_u64(), randomness: fs::Fs::random(rng), }; diff --git a/sapling-crypto/src/circuit/sha256.rs b/sapling-crypto/src/circuit/sha256.rs index 86147f8..3b32282 100644 --- a/sapling-crypto/src/circuit/sha256.rs +++ b/sapling-crypto/src/circuit/sha256.rs @@ -308,7 +308,8 @@ mod test { use circuit::boolean::AllocatedBit; use pairing::bls12_381::Bls12; use circuit::test::TestConstraintSystem; - use rand::{XorShiftRng, SeedableRng, Rng}; + use rand_core::{RngCore, SeedableRng}; + use rand_xorshift::XorShiftRng; #[test] fn test_blank_hash() { @@ -353,7 +354,7 @@ mod test { Boolean::from( AllocatedBit::alloc( cs.namespace(|| format!("input bit {}", i)), - Some(rng.gen()) + Some(rng.next_u32() % 2 != 0) ).unwrap() ) }).collect(); @@ -380,7 +381,7 @@ mod test { for input_len in (0..32).chain((32..256).filter(|a| a % 8 == 0)) { let mut h = Sha256::new(); - let data: Vec = (0..input_len).map(|_| rng.gen()).collect(); + let data: Vec = (0..input_len).map(|_| rng.next_u32() as u8).collect(); h.input(&data); let hash_result = h.result(); diff --git a/sapling-crypto/src/circuit/uint32.rs b/sapling-crypto/src/circuit/uint32.rs index daca627..939b544 100644 --- a/sapling-crypto/src/circuit/uint32.rs +++ b/sapling-crypto/src/circuit/uint32.rs @@ -409,7 +409,6 @@ impl UInt32 { #[cfg(test)] mod test { - use rand::{XorShiftRng, SeedableRng, Rng}; use ::circuit::boolean::{Boolean}; use super::{UInt32}; use ff::Field; @@ -417,6 +416,8 @@ mod test { use ::circuit::test::*; use bellman::{ConstraintSystem}; use circuit::multieq::MultiEq; + use rand_core::{RngCore, SeedableRng}; + use rand_xorshift::XorShiftRng; #[test] fn test_uint32_from_bits_be() { @@ -426,7 +427,7 @@ mod test { ]); for _ in 0..1000 { - let mut v = (0..32).map(|_| Boolean::constant(rng.gen())).collect::>(); + let mut v = (0..32).map(|_| Boolean::constant(rng.next_u32() % 2 != 0)).collect::>(); let b = UInt32::from_bits_be(&v); @@ -460,7 +461,7 @@ mod test { ]); for _ in 0..1000 { - let mut v = (0..32).map(|_| Boolean::constant(rng.gen())).collect::>(); + let mut v = (0..32).map(|_| Boolean::constant(rng.next_u32() % 2 != 0)).collect::>(); let b = UInt32::from_bits(&v); @@ -496,9 +497,9 @@ mod test { for _ in 0..1000 { let mut cs = TestConstraintSystem::::new(); - let a: u32 = rng.gen(); - let b: u32 = rng.gen(); - let c: u32 = rng.gen(); + let a = rng.next_u32(); + let b = rng.next_u32(); + let c = rng.next_u32(); let mut expected = a ^ b ^ c; @@ -541,9 +542,9 @@ mod test { for _ in 0..1000 { let mut cs = TestConstraintSystem::::new(); - let a: u32 = rng.gen(); - let b: u32 = rng.gen(); - let c: u32 = rng.gen(); + let a = rng.next_u32(); + let b = rng.next_u32(); + let c = rng.next_u32(); let a_bit = UInt32::constant(a); let b_bit = UInt32::constant(b); @@ -583,10 +584,10 @@ mod test { for _ in 0..1000 { let mut cs = TestConstraintSystem::::new(); - let a: u32 = rng.gen(); - let b: u32 = rng.gen(); - let c: u32 = rng.gen(); - let d: u32 = rng.gen(); + let a = rng.next_u32(); + let b = rng.next_u32(); + let c = rng.next_u32(); + let d = rng.next_u32(); let mut expected = (a ^ b).wrapping_add(c).wrapping_add(d); @@ -640,7 +641,7 @@ mod test { 0xe5, ]); - let mut num = rng.gen(); + let mut num = rng.next_u32(); let a = UInt32::constant(num); @@ -675,7 +676,7 @@ mod test { for _ in 0..50 { for i in 0..60 { - let num = rng.gen(); + let num = rng.next_u32(); let a = UInt32::constant(num).shr(i); let b = UInt32::constant(num.wrapping_shr(i as u32)); @@ -699,9 +700,9 @@ mod test { for _ in 0..1000 { let mut cs = TestConstraintSystem::::new(); - let a: u32 = rng.gen(); - let b: u32 = rng.gen(); - let c: u32 = rng.gen(); + let a = rng.next_u32(); + let b = rng.next_u32(); + let c = rng.next_u32(); let mut expected = (a & b) ^ (a & c) ^ (b & c); @@ -743,9 +744,9 @@ mod test { for _ in 0..1000 { let mut cs = TestConstraintSystem::::new(); - let a: u32 = rng.gen(); - let b: u32 = rng.gen(); - let c: u32 = rng.gen(); + let a = rng.next_u32(); + let b = rng.next_u32(); + let c = rng.next_u32(); let mut expected = (a & b) ^ ((!a) & c); diff --git a/sapling-crypto/src/jubjub/edwards.rs b/sapling-crypto/src/jubjub/edwards.rs index 95b6120..e912aca 100644 --- a/sapling-crypto/src/jubjub/edwards.rs +++ b/sapling-crypto/src/jubjub/edwards.rs @@ -8,9 +8,7 @@ use super::{ montgomery }; -use rand::{ - Rng -}; +use rand_core::RngCore; use std::marker::PhantomData; @@ -185,12 +183,13 @@ impl Point { convert_subgroup(&tmp) } - pub fn rand(rng: &mut R, params: &E::Params) -> Self + pub fn rand(rng: &mut R, params: &E::Params) -> Self { loop { let y = E::Fr::random(rng); + let sign = rng.next_u32() % 2 != 0; - if let Some(p) = Self::get_for_y(y, rng.gen(), params) { + if let Some(p) = Self::get_for_y(y, sign, params) { return p; } } diff --git a/sapling-crypto/src/jubjub/fs.rs b/sapling-crypto/src/jubjub/fs.rs index 55df2cb..017292b 100644 --- a/sapling-crypto/src/jubjub/fs.rs +++ b/sapling-crypto/src/jubjub/fs.rs @@ -4,7 +4,7 @@ use ff::{ LegendreSymbol::{self, *}, PrimeField, PrimeFieldDecodingError, PrimeFieldRepr, SqrtField, }; -use rand::RngCore; +use rand_core::RngCore; use super::ToUniform; @@ -620,7 +620,9 @@ fn test_neg_one() { } #[cfg(test)] -use rand::{SeedableRng, XorShiftRng}; +use rand_core::SeedableRng; +#[cfg(test)] +use rand_xorshift::XorShiftRng; #[test] fn test_fs_repr_ordering() { diff --git a/sapling-crypto/src/jubjub/montgomery.rs b/sapling-crypto/src/jubjub/montgomery.rs index 28dce8e..9bd6023 100644 --- a/sapling-crypto/src/jubjub/montgomery.rs +++ b/sapling-crypto/src/jubjub/montgomery.rs @@ -8,9 +8,7 @@ use super::{ edwards }; -use rand::{ - Rng -}; +use rand_core::RngCore; use std::marker::PhantomData; @@ -101,12 +99,13 @@ impl Point { convert_subgroup(&tmp) } - pub fn rand(rng: &mut R, params: &E::Params) -> Self + pub fn rand(rng: &mut R, params: &E::Params) -> Self { loop { let x = E::Fr::random(rng); + let sign = rng.next_u32() % 2 != 0; - match Self::get_for_x(x, rng.gen(), params) { + match Self::get_for_x(x, sign, params) { Some(p) => { return p }, diff --git a/sapling-crypto/src/jubjub/tests.rs b/sapling-crypto/src/jubjub/tests.rs index 19aae80..e15b81e 100644 --- a/sapling-crypto/src/jubjub/tests.rs +++ b/sapling-crypto/src/jubjub/tests.rs @@ -14,7 +14,8 @@ use ff::{ LegendreSymbol }; -use rand::{RngCore, XorShiftRng, SeedableRng}; +use rand_core::{RngCore, SeedableRng}; +use rand_xorshift::XorShiftRng; pub fn test_suite(params: &E::Params) { test_back_and_forth::(params); diff --git a/sapling-crypto/src/lib.rs b/sapling-crypto/src/lib.rs index da3bbc4..14e713d 100644 --- a/sapling-crypto/src/lib.rs +++ b/sapling-crypto/src/lib.rs @@ -4,13 +4,16 @@ extern crate blake2b_simd; extern crate blake2s_simd; extern crate digest; extern crate ff; -extern crate rand; +extern crate rand_core; extern crate byteorder; #[cfg(test)] #[macro_use] extern crate hex_literal; +#[cfg(test)] +extern crate rand_xorshift; + #[cfg(test)] extern crate sha2; diff --git a/sapling-crypto/src/redjubjub.rs b/sapling-crypto/src/redjubjub.rs index 2b34654..cd02347 100644 --- a/sapling-crypto/src/redjubjub.rs +++ b/sapling-crypto/src/redjubjub.rs @@ -2,7 +2,7 @@ //! See section 5.4.6 of the Sapling protocol specification. use ff::{Field, PrimeField, PrimeFieldRepr}; -use rand::{Rng}; +use rand_core::RngCore; use std::io::{self, Read, Write}; use jubjub::{FixedGenerators, JubjubEngine, JubjubParams, Unknown, edwards::Point}; @@ -71,7 +71,7 @@ impl PrivateKey { write_scalar::(&self.0, writer) } - pub fn sign( + pub fn sign( &self, msg: &[u8], rng: &mut R, @@ -163,7 +163,7 @@ pub struct BatchEntry<'a, E: JubjubEngine> { // TODO: #82: This is a naive implementation currently, // and doesn't use multiexp. -pub fn batch_verify<'a, E: JubjubEngine, R: Rng>( +pub fn batch_verify<'a, E: JubjubEngine, R: RngCore>( rng: &mut R, batch: &[BatchEntry<'a, E>], p_g: FixedGenerators, @@ -206,7 +206,8 @@ pub fn batch_verify<'a, E: JubjubEngine, R: Rng>( #[cfg(test)] mod tests { use pairing::bls12_381::Bls12; - use rand::thread_rng; + use rand_core::SeedableRng; + use rand_xorshift::XorShiftRng; use jubjub::{JubjubBls12, fs::Fs, edwards}; @@ -214,7 +215,10 @@ mod tests { #[test] fn test_batch_verify() { - let rng = &mut thread_rng(); + let rng = &mut XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let params = &JubjubBls12::new(); let p_g = FixedGenerators::SpendingKeyGenerator; @@ -244,7 +248,10 @@ mod tests { #[test] fn cofactor_check() { - let rng = &mut thread_rng(); + let rng = &mut XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let params = &JubjubBls12::new(); let zero = edwards::Point::zero(); let p_g = FixedGenerators::SpendingKeyGenerator; @@ -276,7 +283,10 @@ mod tests { #[test] fn round_trip_serialization() { - let rng = &mut thread_rng(); + let rng = &mut XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let p_g = FixedGenerators::SpendingKeyGenerator; let params = &JubjubBls12::new(); @@ -309,7 +319,10 @@ mod tests { #[test] fn random_signatures() { - let rng = &mut thread_rng(); + let rng = &mut XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, + 0xe5, + ]); let p_g = FixedGenerators::SpendingKeyGenerator; let params = &JubjubBls12::new();