@@ -1225,27 +1225,15 @@ impl<F: FieldWitness> InnerCurve<F> {
1225
1225
Self { inner }
1226
1226
}
1227
1227
1228
- fn fake_random ( ) -> Self {
1229
- // static SEED: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
1230
- // dbg!(SEED.load(std::sync::atomic::Ordering::Relaxed) );
1228
+ pub fn random ( ) -> Self {
1229
+ // NOTE: Not random in `cfg(test)`
1230
+ let mut rng = get_rng ( ) ;
1231
1231
1232
- let mut rng: rand:: rngs:: StdRng = rand:: SeedableRng :: seed_from_u64 (
1233
- 0 ,
1234
- // SEED.fetch_add(1, std::sync::atomic::Ordering::Relaxed),
1235
- ) ;
1232
+ // Both `proj` below are the same type, but we use `into()` to make it generic
1236
1233
let proj: GroupProjective < F :: Parameters > = ark_ff:: UniformRand :: rand ( & mut rng) ;
1237
1234
let proj: F :: Projective = proj. into ( ) ;
1238
- Self { inner : proj }
1239
- }
1240
-
1241
- pub fn random ( ) -> Self {
1242
- Self :: fake_random ( )
1243
- // // Both `proj` below are the same type, but we use `into()` to make it generic
1244
- // let rng = &mut rand::rngs::OsRng;
1245
- // let proj: GroupProjective<F::Parameters> = ark_ff::UniformRand::rand(rng);
1246
- // let proj: F::Projective = proj.into();
1247
1235
1248
- // Self { inner: proj }
1236
+ Self { inner : proj }
1249
1237
}
1250
1238
}
1251
1239
@@ -3877,6 +3865,17 @@ fn make_prover_index<C: ProofConstants, F: FieldWitness>(
3877
3865
index
3878
3866
}
3879
3867
3868
+ /// During tests, we don't want randomness, to get reproducible witness/proofs
3869
+ /// TODO: Are there other cases where we don't want randomness ?
3870
+ #[ cfg( test) ]
3871
+ fn get_rng ( ) -> rand:: rngs:: StdRng {
3872
+ <rand:: rngs:: StdRng as rand:: SeedableRng >:: seed_from_u64 ( 0 )
3873
+ }
3874
+ #[ cfg( not( test) ) ]
3875
+ fn get_rng ( ) -> rand:: rngs:: OsRng {
3876
+ rand:: rngs:: OsRng
3877
+ }
3878
+
3880
3879
pub fn create_proof < C : ProofConstants , F : FieldWitness > (
3881
3880
prover : & Prover < F > ,
3882
3881
prev_challenges : Vec < RecursionChallenge < F :: OtherCurve > > ,
@@ -3887,7 +3886,9 @@ pub fn create_proof<C: ProofConstants, F: FieldWitness>(
3887
3886
let computed_witness: [ Vec < F > ; COLUMNS ] = compute_witness :: < C , _ > ( prover, w) ;
3888
3887
let prover_index: & ProverIndex < F :: OtherCurve > = & prover. index ;
3889
3888
3890
- let mut rng: rand:: rngs:: StdRng = rand:: SeedableRng :: seed_from_u64 ( 0 ) ;
3889
+ // NOTE: Not random in `cfg(test)`
3890
+ let mut rng = get_rng ( ) ;
3891
+
3891
3892
let now = std:: time:: Instant :: now ( ) ;
3892
3893
let group_map = kimchi:: groupmap:: GroupMap :: < F :: Scalar > :: setup ( ) ;
3893
3894
let proof = kimchi:: proof:: ProverProof :: create_recursive :: < F :: FqSponge , EFrSponge < F > > (
0 commit comments