From d00dbc5a023c486334d31caf6944b5f60bab5c32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Mon, 1 Apr 2024 13:13:59 +0200 Subject: [PATCH] preparing for refactor 4 --- ferveo/src/refresh.rs | 102 +++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/ferveo/src/refresh.rs b/ferveo/src/refresh.rs index a7af4f2c..75ff1f20 100644 --- a/ferveo/src/refresh.rs +++ b/ferveo/src/refresh.rs @@ -93,41 +93,41 @@ impl PrivateKeyShare { // Perhaps RecoveryShare, or something /// From the PSS paper, section 4.2.4, (https://link.springer.com/content/pdf/10.1007/3-540-44750-4_27.pdf) /// `x_r` is the point at which the share is to be recovered - pub fn recover_share_from_updated_private_shares( - // TODO: Consider hiding x_r from the public API - x_r: &DomainPoint, - domain_points: &HashMap>, - // TODO: recovery_shares? - updated_shares: &HashMap>, - ) -> Result> { - // Pick the domain points and updated shares according to share index - let mut domain_points_ = vec![]; - let mut updated_shares_ = vec![]; - for share_index in updated_shares.keys().sorted() { - domain_points_.push( - *domain_points - .get(share_index) - .ok_or(Error::InvalidShareIndex(*share_index))?, - ); - updated_shares_.push( - updated_shares - .get(share_index) - .ok_or(Error::InvalidShareIndex(*share_index))? - .0 - .clone(), - ); - } - - // Interpolate new shares to recover y_r - // TODO: check if this logic is repeated a bunch of times in other places - let lagrange = lagrange_basis_at::(&domain_points_, x_r); - let prods = - zip_eq(updated_shares_, lagrange).map(|(y_j, l)| y_j.0.mul(l)); - let y_r = prods.fold(E::G2::zero(), |acc, y_j| acc + y_j); - Ok(PrivateKeyShare(ferveo_tdec::PrivateKeyShare( - y_r.into_affine(), - ))) - } + // pub fn recover_share_from_updated_private_shares( + // // TODO: Consider hiding x_r from the public API + // x_r: &DomainPoint, + // domain_points: &HashMap>, + // // TODO: recovery_shares? + // updated_shares: &HashMap>, + // ) -> Result> { + // // Pick the domain points and updated shares according to share index + // let mut domain_points_ = vec![]; + // let mut updated_shares_ = vec![]; + // for share_index in updated_shares.keys().sorted() { + // domain_points_.push( + // *domain_points + // .get(share_index) + // .ok_or(Error::InvalidShareIndex(*share_index))?, + // ); + // updated_shares_.push( + // updated_shares + // .get(share_index) + // .ok_or(Error::InvalidShareIndex(*share_index))? + // .0 + // .clone(), + // ); + // } + + // // Interpolate new shares to recover y_r + // // TODO: check if this logic is repeated a bunch of times in other places + // let lagrange = lagrange_basis_at::(&domain_points_, x_r); + // let prods = + // zip_eq(updated_shares_, lagrange).map(|(y_j, l)| y_j.0.mul(l)); + // let y_r = prods.fold(E::G2::zero(), |acc, y_j| acc + y_j); + // Ok(PrivateKeyShare(ferveo_tdec::PrivateKeyShare( + // y_r.into_affine(), + // ))) + // } pub fn create_decryption_share_simple( &self, @@ -673,14 +673,14 @@ mod tests_refresh { (share_index, UpdatedPrivateKeyShare(share)) }) .collect::>(); - let new_shared_private_key = - PrivateKeyShare::recover_share_from_updated_private_shares( - &ScalarField::zero(), - domain_points, - &updated_private_key_shares, - ) - .unwrap(); - assert_eq!(shared_private_key, new_shared_private_key.0); + // let new_shared_private_key = + // PrivateKeyShare::recover_share_from_updated_private_shares( + // &ScalarField::zero(), + // domain_points, + // &updated_private_key_shares, + // ) + // .unwrap(); + assert_ne!(shared_private_key, shared_private_key); } /// Ñ parties (where t <= Ñ <= N) jointly execute a "share refresh" algorithm. @@ -798,13 +798,13 @@ mod tests_refresh { .collect::>>(); // Finally, let's recreate the shared private key from the refreshed shares - let new_shared_private_key = - PrivateKeyShare::recover_share_from_updated_private_shares( - &ScalarField::zero(), - &domain_points, - &refreshed_shares, - ) - .unwrap(); - assert_eq!(shared_private_key, new_shared_private_key.0); + // let new_shared_private_key = + // PrivateKeyShare::recover_share_from_updated_private_shares( + // &ScalarField::zero(), + // &domain_points, + // &refreshed_shares, + // ) + // .unwrap(); + assert_ne!(shared_private_key, shared_private_key); } }