diff options
Diffstat (limited to 'third_party/rust/prio/src/dp')
-rw-r--r-- | third_party/rust/prio/src/dp/distributions.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/third_party/rust/prio/src/dp/distributions.rs b/third_party/rust/prio/src/dp/distributions.rs index ba0270df9c..5fc42f96ec 100644 --- a/third_party/rust/prio/src/dp/distributions.rs +++ b/third_party/rust/prio/src/dp/distributions.rs @@ -292,7 +292,7 @@ mod tests { use super::*; use crate::dp::Rational; - use crate::vdaf::xof::SeedStreamSha3; + use crate::vdaf::xof::SeedStreamTurboShake128; use num_bigint::{BigUint, Sign, ToBigInt, ToBigUint}; use num_traits::{One, Signed, ToPrimitive}; @@ -306,15 +306,15 @@ mod tests { DiscreteGaussian::new(Ratio::<BigUint>::from_integer(BigUint::from(5u8))).unwrap(); // check samples are consistent - let mut rng = SeedStreamSha3::from_seed([0u8; 16]); + let mut rng = SeedStreamTurboShake128::from_seed([0u8; 16]); let samples: Vec<i8> = (0..10) .map(|_| i8::try_from(sampler.sample(&mut rng)).unwrap()) .collect(); let samples1: Vec<i8> = (0..10) .map(|_| i8::try_from(sampler.sample(&mut rng)).unwrap()) .collect(); - assert_eq!(samples, vec![-3, -11, -3, 5, 1, 5, 2, 2, 1, 18]); - assert_eq!(samples1, vec![4, -4, -5, -2, 0, -5, -3, 1, 1, -2]); + assert_eq!(samples, vec![0, -3, -2, 3, 2, -1, -5, 4, -7, -5]); + assert_eq!(samples1, vec![2, 7, -8, -3, 1, -3, -3, 6, -3, -1]); } #[test] @@ -325,7 +325,7 @@ mod tests { // sample from a manually created distribution let sampler1 = DiscreteGaussian::new(Ratio::<BigUint>::from_integer(BigUint::from(4u8))).unwrap(); - let mut rng = SeedStreamSha3::from_seed([0u8; 16]); + let mut rng = SeedStreamTurboShake128::from_seed([0u8; 16]); let samples1: Vec<i8> = (0..10) .map(|_| i8::try_from(sampler1.sample(&mut rng)).unwrap()) .collect(); @@ -337,7 +337,7 @@ mod tests { let sampler2 = zcdp .create_distribution(Ratio::<BigUint>::from_integer(1u8.into())) .unwrap(); - let mut rng2 = SeedStreamSha3::from_seed([0u8; 16]); + let mut rng2 = SeedStreamTurboShake128::from_seed([0u8; 16]); let samples2: Vec<i8> = (0..10) .map(|_| i8::try_from(sampler2.sample(&mut rng2)).unwrap()) .collect(); @@ -485,7 +485,7 @@ mod tests { .unwrap(); // collect that number of samples - let mut rng = SeedStreamSha3::from_seed([0u8; 16]); + let mut rng = SeedStreamTurboShake128::from_seed([0u8; 16]); let samples: Vec<BigInt> = (1..n_samples) .map(|_| { sample_discrete_gaussian(&Ratio::<BigUint>::from_integer(sigma.clone()), &mut rng) @@ -519,7 +519,7 @@ mod tests { #[test] fn empirical_test_gauss() { [100, 2000, 20000].iter().for_each(|p| { - let mut rng = SeedStreamSha3::from_seed([0u8; 16]); + let mut rng = SeedStreamTurboShake128::from_seed([0u8; 16]); let sampler = || { sample_discrete_gaussian( &Ratio::<BigUint>::from_integer((*p).to_biguint().unwrap()), @@ -541,7 +541,7 @@ mod tests { #[test] fn empirical_test_bernoulli_mean() { [2u8, 5u8, 7u8, 9u8].iter().for_each(|p| { - let mut rng = SeedStreamSha3::from_seed([0u8; 16]); + let mut rng = SeedStreamTurboShake128::from_seed([0u8; 16]); let sampler = || { if sample_bernoulli( &Ratio::<BigUint>::new(BigUint::one(), (*p).into()), @@ -565,7 +565,7 @@ mod tests { #[test] fn empirical_test_geometric_mean() { [2u8, 5u8, 7u8, 9u8].iter().for_each(|p| { - let mut rng = SeedStreamSha3::from_seed([0u8; 16]); + let mut rng = SeedStreamTurboShake128::from_seed([0u8; 16]); let sampler = || { sample_geometric_exp( &Ratio::<BigUint>::new(BigUint::one(), (*p).into()), @@ -588,7 +588,7 @@ mod tests { #[test] fn empirical_test_laplace_mean() { [2u8, 5u8, 7u8, 9u8].iter().for_each(|p| { - let mut rng = SeedStreamSha3::from_seed([0u8; 16]); + let mut rng = SeedStreamTurboShake128::from_seed([0u8; 16]); let sampler = || { sample_discrete_laplace( &Ratio::<BigUint>::new(BigUint::one(), (*p).into()), |