diff --git a/Cargo.toml b/Cargo.toml index 7bd31ee..3c83bd7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,8 +30,6 @@ num-bigint = {version = "0.3", default-features = false } num-traits = {version = "0.2", default-features = false } [dev-dependencies] -rand = { version = "0.7", default-features = false } -rand_xorshift = "0.2" ark-test-curves = { git = "https://github.com/arkworks-rs/algebra", default-features = false, features = ["bls12_381_scalar_field", "mnt4_753_scalar_field"] } [features] diff --git a/src/bits/boolean.rs b/src/bits/boolean.rs index 8b56acf..b68e511 100644 --- a/src/bits/boolean.rs +++ b/src/bits/boolean.rs @@ -959,8 +959,6 @@ mod test { use ark_ff::{BitIteratorBE, BitIteratorLE, Field, One, PrimeField, UniformRand, Zero}; use ark_relations::r1cs::{ConstraintSystem, Namespace, SynthesisError}; use ark_test_curves::bls12_381::Fr; - use rand::SeedableRng; - use rand_xorshift::XorShiftRng; #[test] fn test_boolean_to_byte() -> Result<(), SynthesisError> { @@ -1634,7 +1632,7 @@ mod test { #[test] fn test_smaller_than_or_equal_to() -> Result<(), SynthesisError> { - let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + let mut rng = ark_std::test_rng(); for _ in 0..1000 { let mut r = Fr::rand(&mut rng); let mut s = Fr::rand(&mut rng); @@ -1688,7 +1686,7 @@ mod test { assert!(!cs.is_satisfied().unwrap()); } - let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + let mut rng = ark_std::test_rng(); for _ in 0..1000 { let r = Fr::rand(&mut rng); diff --git a/src/bits/uint.rs b/src/bits/uint.rs index 880238e..c884bad 100644 --- a/src/bits/uint.rs +++ b/src/bits/uint.rs @@ -386,12 +386,11 @@ macro_rules! make_uint { use crate::{bits::boolean::Boolean, prelude::*, Vec}; use ark_test_curves::mnt4_753::Fr; use ark_relations::r1cs::{ConstraintSystem, SynthesisError}; - use rand::{Rng, SeedableRng}; - use rand_xorshift::XorShiftRng; + use ark_std::rand::Rng; #[test] fn test_from_bits() -> Result<(), SynthesisError> { - let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + let mut rng = ark_std::test_rng(); for _ in 0..1000 { let v = (0..$size) @@ -425,7 +424,7 @@ macro_rules! make_uint { #[test] fn test_xor() -> Result<(), SynthesisError> { use Boolean::*; - let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + let mut rng = ark_std::test_rng(); for _ in 0..1000 { let cs = ConstraintSystem::::new_ref(); @@ -462,7 +461,7 @@ macro_rules! make_uint { #[test] fn test_addmany_constants() -> Result<(), SynthesisError> { - let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + let mut rng = ark_std::test_rng(); for _ in 0..1000 { let cs = ConstraintSystem::::new_ref(); @@ -496,7 +495,7 @@ macro_rules! make_uint { #[test] fn test_addmany() -> Result<(), SynthesisError> { - let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + let mut rng = ark_std::test_rng(); for _ in 0..1000 { let cs = ConstraintSystem::::new_ref(); @@ -534,7 +533,7 @@ macro_rules! make_uint { #[test] fn test_rotr() -> Result<(), SynthesisError> { - let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + let mut rng = ark_std::test_rng(); let mut num = rng.gen(); diff --git a/src/bits/uint8.rs b/src/bits/uint8.rs index 69e2eeb..dd479d0 100644 --- a/src/bits/uint8.rs +++ b/src/bits/uint8.rs @@ -365,10 +365,9 @@ mod test { use crate::{prelude::*, ToConstraintFieldGadget, Vec}; use ark_ff::{FpParameters, PrimeField, ToConstraintField}; use ark_relations::r1cs::{ConstraintSystem, SynthesisError}; + use ark_std::rand::distributions::Uniform; + use ark_std::rand::Rng; use ark_test_curves::bls12_381::Fr; - use rand::distributions::Uniform; - use rand::{Rng, SeedableRng}; - use rand_xorshift::XorShiftRng; #[test] fn test_uint8_from_bits_to_bits() -> Result<(), SynthesisError> { @@ -407,7 +406,7 @@ mod test { #[test] fn test_uint8_from_bits() -> Result<(), SynthesisError> { - let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + let mut rng = ark_std::test_rng(); for _ in 0..1000 { let v = (0..8) @@ -438,7 +437,7 @@ mod test { #[test] fn test_uint8_xor() -> Result<(), SynthesisError> { - let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + let mut rng = ark_std::test_rng(); for _ in 0..1000 { let cs = ConstraintSystem::::new_ref(); @@ -475,7 +474,7 @@ mod test { #[test] fn test_uint8_to_constraint_field() -> Result<(), SynthesisError> { - let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + let mut rng = ark_std::test_rng(); let max_size = (::Params::CAPACITY / 8) as usize; let modes = [Input, Witness, Constant]; @@ -506,7 +505,7 @@ mod test { #[test] fn test_uint8_random_access() { - let mut rng = XorShiftRng::seed_from_u64(1231275789u64); + let mut rng = ark_std::test_rng(); for _ in 0..100 { let cs = ConstraintSystem::::new_ref(); diff --git a/src/fields/fp/cmp.rs b/src/fields/fp/cmp.rs index 58f7cf4..5a82635 100644 --- a/src/fields/fp/cmp.rs +++ b/src/fields/fp/cmp.rs @@ -153,9 +153,8 @@ impl FpVar { #[cfg(test)] mod test { - use rand::{Rng, SeedableRng}; - use rand_xorshift::XorShiftRng; - use std::cmp::Ordering; + use ark_std::cmp::Ordering; + use ark_std::rand::Rng; use crate::{alloc::AllocVar, fields::fp::FpVar}; use ark_ff::{PrimeField, UniformRand}; @@ -164,10 +163,7 @@ mod test { #[test] fn test_cmp() { - let mut rng = &mut XorShiftRng::from_seed([ - 0x5d, 0xbe, 0x62, 0x59, 0x8d, 0x31, 0x3d, 0x76, 0x32, 0x37, 0xdb, 0x17, 0xe5, 0xbc, - 0x06, 0x54, - ]); + let mut rng = ark_std::test_rng(); fn rand_in_range(rng: &mut R) -> Fr { let pminusonedivtwo: Fr = Fr::modulus_minus_one_div_two().into(); let mut r;