Skip to content

Commit

Permalink
Remove redundant calls to shares_generate in make_and_reconstruct_sha…
Browse files Browse the repository at this point in the history
…res.
  • Loading branch information
lthibault committed Sep 24, 2024
1 parent 6764a72 commit d6db3e7
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/qos_crypto/src/shamir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,13 @@ mod test {

// Reconstruct with all the shares
let shares = all_shares.clone();
let reconstructed = shares_reconstruct(&shares).unwrap();
let old_reconstructed = shares_reconstruct(&shares).unwrap();
let reconstructed = shares_reconstruct(shares).unwrap();
assert_eq!(secret.to_vec(), reconstructed);
assert_eq!(secret.to_vec(), old_reconstructed);

// Reconstruct with enough shares
let shares = &all_shares[..k];
let reconstructed = shares_reconstruct(shares).unwrap();
let old_reconstructed = shares_reconstruct(shares).unwrap();
assert_eq!(secret.to_vec(), reconstructed);
assert_eq!(secret.to_vec(), old_reconstructed);

// Reconstruct with not enough shares
let shares = &all_shares[..(k - 1)];
Expand All @@ -68,15 +64,11 @@ mod test {
let mut shares = all_shares.clone()[..k].to_vec();
shares.shuffle(&mut rand::thread_rng());
let reconstructed = shares_reconstruct(&shares).unwrap();
let old_reconstructed = shares_reconstruct(&shares).unwrap();
assert_eq!(secret.to_vec(), reconstructed);
assert_eq!(secret.to_vec(), old_reconstructed);

for combo in crate::n_choose_k::combinations(&all_shares, k) {
let reconstructed = shares_reconstruct(&combo).unwrap();
let old_reconstructed = shares_reconstruct(&shares).unwrap();
assert_eq!(secret.to_vec(), reconstructed);
assert_eq!(secret.to_vec(), old_reconstructed);
}
}
}

0 comments on commit d6db3e7

Please sign in to comment.