Polish test
This commit is contained in:
parent
4983e2c728
commit
e6be185d3d
23
src/lib.rs
23
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::<Fp>::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
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue