Skip to content

Commit 223e359

Browse files
committed
Reuse Goldilocks random
1 parent 8aa5d6f commit 223e359

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

spartan_parallel/src/scalar/fp.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use core::borrow::Borrow;
44
use core::iter::{Product, Sum};
55
use core::ops::{Add, AddAssign, Mul, MulAssign, Sub, SubAssign};
66
use ff::{Field, FromUniformBytes};
7-
use goldilocks::{Goldilocks, MODULUS as P};
7+
use goldilocks::Goldilocks;
88
use rand::{CryptoRng, RngCore};
99
use serde::{Deserialize, Serialize};
1010
use std::ops::Neg;
@@ -31,11 +31,7 @@ impl SpartanExtensionField for Scalar {
3131
}
3232

3333
fn random<Rng: RngCore + CryptoRng>(rng: &mut Rng) -> Self {
34-
let mut res = rng.next_u64();
35-
while res >= P {
36-
res = rng.next_u64();
37-
}
38-
Goldilocks(res).into()
34+
Goldilocks::random(rng).into()
3935
}
4036

4137
/// Attempts to convert a little-endian byte representation of

spartan_parallel/src/scalar/fp2.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use super::Scalar;
21
use super::SpartanExtensionField;
32
use crate::{AppendToTranscript, ProofTranscript, Transcript};
43
use core::borrow::Borrow;
@@ -37,7 +36,7 @@ impl SpartanExtensionField for ScalarExt2 {
3736
}
3837

3938
fn random<Rng: RngCore + CryptoRng>(rng: &mut Rng) -> Self {
40-
GoldilocksExt2([*Scalar::random(rng).inner(), *Scalar::random(rng).inner()]).into()
39+
GoldilocksExt2::random(rng).into()
4140
}
4241

4342
/// Attempts to convert a little-endian byte representation of

0 commit comments

Comments
 (0)