From a7bbcafc4f6626d146a9bfef868d97d4d7d7331b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Wed, 20 Mar 2024 11:02:18 +0100 Subject: [PATCH] Move methods to create updates from ShareUpdate to UpdateTranscript --- ferveo/src/refresh.rs | 47 ++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/ferveo/src/refresh.rs b/ferveo/src/refresh.rs index 25cccfe7..4bd83340 100644 --- a/ferveo/src/refresh.rs +++ b/ferveo/src/refresh.rs @@ -210,8 +210,31 @@ pub struct ShareUpdate { } impl ShareUpdate { + + // TODO: Unit tests + pub fn verify(&self, target_validator_public_key: E::G2) -> Result { + let is_valid = E::pairing(E::G1::generator(), self.update) + == E::pairing(self.commitment, target_validator_public_key); + if is_valid{ + Ok(true) + } else { + Err(Error::InvalidShareUpdate) + } + } +} + +// TODO: Reconsider naming +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct UpdateTranscript { + /// Used in Feldman commitment to the update polynomial + pub coeffs: Vec, + + /// The share updates to be dealt to each validator + pub updates: HashMap>, +} + +impl UpdateTranscript { /// From PSS paper, section 4.2.1, (https://link.springer.com/content/pdf/10.1007/3-540-44750-4_27.pdf) - // TODO: working pub fn create_refresh_updates( domain_points_and_keys: &HashMap, E::G2)>, // FIXME: eeewww threshold: u32, @@ -242,28 +265,6 @@ impl ShareUpdate { ) // TODO: Cast return elements into ShareRecoveryUpdate } - - // TODO: Unit tests - pub fn verify(&self, target_validator_public_key: E::G2) -> Result { - let is_valid = E::pairing(E::G1::generator(), self.update) - == E::pairing(self.commitment, target_validator_public_key); - if is_valid{ - Ok(true) - } else { - Err(Error::InvalidShareUpdate) - } - } -} - - -// TODO: Reconsider naming -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct UpdateTranscript { - /// Used in Feldman commitment to the update polynomial - pub coeffs: Vec, - - /// The share updates to be dealt to each validator - pub updates: HashMap>, }