Skip to content

Commit

Permalink
Make sure test for recovery at original point is correct
Browse files Browse the repository at this point in the history
  • Loading branch information
cygnusv committed Sep 7, 2023
1 parent fed8911 commit 05f7d3a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions ferveo/src/refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ pub fn refresh_private_key_share<E: Pairing>(
#[cfg(test)]
mod tests_refresh {

use std::{collections::HashMap, ops::Mul};
use std::collections::HashMap;

use ark_bls12_381::Fr;
use ark_ec::{pairing::Pairing, AffineRepr, CurveGroup};
use ark_ec::{pairing::Pairing, AffineRepr};
// use ark_ff::Zero;
use ark_std::{test_rng, UniformRand, Zero};
// use ferveo_common::{FromBytes, ToBytes};
Expand Down Expand Up @@ -273,11 +273,21 @@ mod tests_refresh {
.collect::<Vec<_>>();
let new_private_key_share = recover_share_from_updated_private_shares(
&x_r,
domain_points,
&new_share_fragments,
&domain_points[..threshold],
&new_share_fragments[..threshold],
);

assert_eq!(new_private_key_share, original_private_key_share);

// If we don't have enough private share updates, the resulting private share will be incorrect
let incorrect_private_key_share =
recover_share_from_updated_private_shares(
&x_r,
&domain_points[..(threshold - 1)],
&new_share_fragments[..(threshold - 1)],
);

assert_ne!(incorrect_private_key_share, original_private_key_share);
}

/// Ñ parties (where t <= Ñ <= N) jointly execute a "share recovery" algorithm, and the output is 1 new share.
Expand Down

0 comments on commit 05f7d3a

Please sign in to comment.