From e6be185d3d52bd8f4cf49427152f277fe75123b4 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Sun, 15 Aug 2021 15:27:19 -0700 Subject: [PATCH] Polish test --- src/lib.rs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1a152a6..6e51be6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -234,11 +234,12 @@ mod tests { use std::fmt::{Display, Formatter}; // Generate a Prime Field to Test with... + // This is way larger than the 64 bit prime the paper specifies, but wth #[derive(PrimeField)] - #[PrimeFieldModulus = "65537"] - #[PrimeFieldGenerator = "3"] + #[PrimeFieldModulus = "52435875175126190479447740508185965837690552500527637822603658699938581184513"] + #[PrimeFieldGenerator = "7"] #[PrimeFieldReprEndianness = "little"] - struct Fp([u64; 1]); + struct Fp([u64; 4]); impl Display for Fp { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { @@ -249,18 +250,18 @@ mod tests { #[test] fn it_works() { let rng = OsRng; - let s = 3u64; - let t = 6u64; + let s = 10u64; + let t = 30u64; let dhf = HashKey::::new(rng, s, t); let mut solver = Solver::new(s, t); - for i in 0..10 { + for i in 0..40 { // These are the indexes which are to be random...you can try swapping them around.. // REMEMBER: the number of true hash needs to be AT LEAST `t+1` AND the number of fake hashes // must be AT-MOST `s`. // If |random hashes| > s this this procedure will *not* work // There is an extended algorithm for extract assuming |true hashes| > t though - we do not implement it. - if i != 2 && i != 5 && i != 8 { + if i != 2 && i != 5 && i != 8 && i < 34 { let x0 = Fp::random(rng); let hash = dhf.generate_hash(x0); solver.add_hash(hash); @@ -269,6 +270,12 @@ mod tests { } } - assert_eq!(solver.attempt_solve().unwrap(), vec![0, 1, 3, 4, 6, 7, 9]); + assert_eq!( + solver.attempt_solve().unwrap(), + vec![ + 0, 1, 3, 4, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33 + ] + ); } }