Skip to content

Commit

Permalink
ShareUpdate verification method
Browse files Browse the repository at this point in the history
  • Loading branch information
cygnusv committed Mar 18, 2024
1 parent 4a75b45 commit e3267c0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ferveo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ pub enum Error {
#[error("Invalid share index: {0}")]
InvalidShareIndex(u32),

/// Failed to verify a share update
#[error("Invalid share update")]
InvalidShareUpdate,

/// Failed to produce a precomputed variant decryption share
#[error("Invalid DKG parameters for precomputed variant: number of shares {0}, threshold {1}")]
InvalidDkgParametersForPrecomputedVariant(u32, u32),
Expand Down
2 changes: 2 additions & 0 deletions ferveo/src/pvss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,12 @@ pub fn do_verify_full<E: Pairing>(
// We verify that e(G, Y_i) = e(A_i, ek_i) for validator i
// See #4 in 4.2.3 section of https://eprint.iacr.org/2022/898.pdf
// e(G,Y) = e(A, ek)
// TODO: consider using multipairing
let is_valid = E::pairing(pvss_params.g, *y_i) == E::pairing(a_i, ek_i);
if !is_valid {
return Ok(false);
}
// TODO: Should we return Err()?
}

Ok(true)
Expand Down
11 changes: 11 additions & 0 deletions ferveo/src/refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,17 @@ impl<E: Pairing> ShareUpdate<E> {
)
// TODO: Cast return elements into ShareRecoveryUpdate
}

// TODO: Unit tests
pub fn verify(&self, target_validator_public_key: E::G2) -> Result<bool> {
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: working here
Expand Down

0 comments on commit e3267c0

Please sign in to comment.