mirror of
https://github.com/arnaucube/ark-r1cs-std.git
synced 2026-01-09 07:21:29 +01:00
replace rand with ark_std::rand and drop rand_xorshift (#51)
This commit is contained in:
@@ -30,8 +30,6 @@ num-bigint = {version = "0.3", default-features = false }
|
|||||||
num-traits = {version = "0.2", default-features = false }
|
num-traits = {version = "0.2", default-features = false }
|
||||||
|
|
||||||
[dev-dependencies]
|
[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"] }
|
ark-test-curves = { git = "https://github.com/arkworks-rs/algebra", default-features = false, features = ["bls12_381_scalar_field", "mnt4_753_scalar_field"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|||||||
@@ -959,8 +959,6 @@ mod test {
|
|||||||
use ark_ff::{BitIteratorBE, BitIteratorLE, Field, One, PrimeField, UniformRand, Zero};
|
use ark_ff::{BitIteratorBE, BitIteratorLE, Field, One, PrimeField, UniformRand, Zero};
|
||||||
use ark_relations::r1cs::{ConstraintSystem, Namespace, SynthesisError};
|
use ark_relations::r1cs::{ConstraintSystem, Namespace, SynthesisError};
|
||||||
use ark_test_curves::bls12_381::Fr;
|
use ark_test_curves::bls12_381::Fr;
|
||||||
use rand::SeedableRng;
|
|
||||||
use rand_xorshift::XorShiftRng;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_boolean_to_byte() -> Result<(), SynthesisError> {
|
fn test_boolean_to_byte() -> Result<(), SynthesisError> {
|
||||||
@@ -1634,7 +1632,7 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_smaller_than_or_equal_to() -> Result<(), SynthesisError> {
|
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 {
|
for _ in 0..1000 {
|
||||||
let mut r = Fr::rand(&mut rng);
|
let mut r = Fr::rand(&mut rng);
|
||||||
let mut s = Fr::rand(&mut rng);
|
let mut s = Fr::rand(&mut rng);
|
||||||
@@ -1688,7 +1686,7 @@ mod test {
|
|||||||
assert!(!cs.is_satisfied().unwrap());
|
assert!(!cs.is_satisfied().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut rng = XorShiftRng::seed_from_u64(1231275789u64);
|
let mut rng = ark_std::test_rng();
|
||||||
|
|
||||||
for _ in 0..1000 {
|
for _ in 0..1000 {
|
||||||
let r = Fr::rand(&mut rng);
|
let r = Fr::rand(&mut rng);
|
||||||
|
|||||||
@@ -386,12 +386,11 @@ macro_rules! make_uint {
|
|||||||
use crate::{bits::boolean::Boolean, prelude::*, Vec};
|
use crate::{bits::boolean::Boolean, prelude::*, Vec};
|
||||||
use ark_test_curves::mnt4_753::Fr;
|
use ark_test_curves::mnt4_753::Fr;
|
||||||
use ark_relations::r1cs::{ConstraintSystem, SynthesisError};
|
use ark_relations::r1cs::{ConstraintSystem, SynthesisError};
|
||||||
use rand::{Rng, SeedableRng};
|
use ark_std::rand::Rng;
|
||||||
use rand_xorshift::XorShiftRng;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_from_bits() -> Result<(), SynthesisError> {
|
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 {
|
for _ in 0..1000 {
|
||||||
let v = (0..$size)
|
let v = (0..$size)
|
||||||
@@ -425,7 +424,7 @@ macro_rules! make_uint {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_xor() -> Result<(), SynthesisError> {
|
fn test_xor() -> Result<(), SynthesisError> {
|
||||||
use Boolean::*;
|
use Boolean::*;
|
||||||
let mut rng = XorShiftRng::seed_from_u64(1231275789u64);
|
let mut rng = ark_std::test_rng();
|
||||||
|
|
||||||
for _ in 0..1000 {
|
for _ in 0..1000 {
|
||||||
let cs = ConstraintSystem::<Fr>::new_ref();
|
let cs = ConstraintSystem::<Fr>::new_ref();
|
||||||
@@ -462,7 +461,7 @@ macro_rules! make_uint {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_addmany_constants() -> Result<(), SynthesisError> {
|
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 {
|
for _ in 0..1000 {
|
||||||
let cs = ConstraintSystem::<Fr>::new_ref();
|
let cs = ConstraintSystem::<Fr>::new_ref();
|
||||||
@@ -496,7 +495,7 @@ macro_rules! make_uint {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_addmany() -> Result<(), SynthesisError> {
|
fn test_addmany() -> Result<(), SynthesisError> {
|
||||||
let mut rng = XorShiftRng::seed_from_u64(1231275789u64);
|
let mut rng = ark_std::test_rng();
|
||||||
|
|
||||||
for _ in 0..1000 {
|
for _ in 0..1000 {
|
||||||
let cs = ConstraintSystem::<Fr>::new_ref();
|
let cs = ConstraintSystem::<Fr>::new_ref();
|
||||||
@@ -534,7 +533,7 @@ macro_rules! make_uint {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rotr() -> Result<(), SynthesisError> {
|
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();
|
let mut num = rng.gen();
|
||||||
|
|
||||||
|
|||||||
@@ -365,10 +365,9 @@ mod test {
|
|||||||
use crate::{prelude::*, ToConstraintFieldGadget, Vec};
|
use crate::{prelude::*, ToConstraintFieldGadget, Vec};
|
||||||
use ark_ff::{FpParameters, PrimeField, ToConstraintField};
|
use ark_ff::{FpParameters, PrimeField, ToConstraintField};
|
||||||
use ark_relations::r1cs::{ConstraintSystem, SynthesisError};
|
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 ark_test_curves::bls12_381::Fr;
|
||||||
use rand::distributions::Uniform;
|
|
||||||
use rand::{Rng, SeedableRng};
|
|
||||||
use rand_xorshift::XorShiftRng;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_uint8_from_bits_to_bits() -> Result<(), SynthesisError> {
|
fn test_uint8_from_bits_to_bits() -> Result<(), SynthesisError> {
|
||||||
@@ -407,7 +406,7 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_uint8_from_bits() -> Result<(), SynthesisError> {
|
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 {
|
for _ in 0..1000 {
|
||||||
let v = (0..8)
|
let v = (0..8)
|
||||||
@@ -438,7 +437,7 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_uint8_xor() -> Result<(), SynthesisError> {
|
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 {
|
for _ in 0..1000 {
|
||||||
let cs = ConstraintSystem::<Fr>::new_ref();
|
let cs = ConstraintSystem::<Fr>::new_ref();
|
||||||
@@ -475,7 +474,7 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_uint8_to_constraint_field() -> Result<(), SynthesisError> {
|
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 = (<Fr as PrimeField>::Params::CAPACITY / 8) as usize;
|
let max_size = (<Fr as PrimeField>::Params::CAPACITY / 8) as usize;
|
||||||
|
|
||||||
let modes = [Input, Witness, Constant];
|
let modes = [Input, Witness, Constant];
|
||||||
@@ -506,7 +505,7 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_uint8_random_access() {
|
fn test_uint8_random_access() {
|
||||||
let mut rng = XorShiftRng::seed_from_u64(1231275789u64);
|
let mut rng = ark_std::test_rng();
|
||||||
|
|
||||||
for _ in 0..100 {
|
for _ in 0..100 {
|
||||||
let cs = ConstraintSystem::<Fr>::new_ref();
|
let cs = ConstraintSystem::<Fr>::new_ref();
|
||||||
|
|||||||
@@ -153,9 +153,8 @@ impl<F: PrimeField> FpVar<F> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use rand::{Rng, SeedableRng};
|
use ark_std::cmp::Ordering;
|
||||||
use rand_xorshift::XorShiftRng;
|
use ark_std::rand::Rng;
|
||||||
use std::cmp::Ordering;
|
|
||||||
|
|
||||||
use crate::{alloc::AllocVar, fields::fp::FpVar};
|
use crate::{alloc::AllocVar, fields::fp::FpVar};
|
||||||
use ark_ff::{PrimeField, UniformRand};
|
use ark_ff::{PrimeField, UniformRand};
|
||||||
@@ -164,10 +163,7 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cmp() {
|
fn test_cmp() {
|
||||||
let mut rng = &mut XorShiftRng::from_seed([
|
let mut rng = ark_std::test_rng();
|
||||||
0x5d, 0xbe, 0x62, 0x59, 0x8d, 0x31, 0x3d, 0x76, 0x32, 0x37, 0xdb, 0x17, 0xe5, 0xbc,
|
|
||||||
0x06, 0x54,
|
|
||||||
]);
|
|
||||||
fn rand_in_range<R: Rng>(rng: &mut R) -> Fr {
|
fn rand_in_range<R: Rng>(rng: &mut R) -> Fr {
|
||||||
let pminusonedivtwo: Fr = Fr::modulus_minus_one_div_two().into();
|
let pminusonedivtwo: Fr = Fr::modulus_minus_one_div_two().into();
|
||||||
let mut r;
|
let mut r;
|
||||||
|
|||||||
Reference in New Issue
Block a user