Check num of commitments against min signers

This commit is contained in:
natalie 2024-01-16 20:46:04 +00:00
parent a1350ea182
commit db48fa2cc8
3 changed files with 9 additions and 5 deletions

View File

@ -39,7 +39,7 @@ pub(crate) fn sum_commitments<C: Ciphersuite>(
let mut group_commitment = vec![
CoefficientCommitment(<C::Group>::identity());
commitments
.get(0)
.first()
.ok_or(Error::IncorrectNumberOfCommitments)?
.0
.len()
@ -407,7 +407,7 @@ where
/// element in the vector), or an error if the vector is empty.
pub(crate) fn verifying_key(&self) -> Result<VerifyingKey<C>, Error<C>> {
Ok(VerifyingKey::new(
self.0.get(0).ok_or(Error::MissingCommitment)?.0,
self.0.first().ok_or(Error::MissingCommitment)?.0,
))
}
@ -614,7 +614,7 @@ fn evaluate_polynomial<C: Ciphersuite>(
}
value = value
+ *coefficients
.get(0)
.first()
.expect("coefficients must have at least one element");
value
}

View File

@ -349,7 +349,7 @@ pub(crate) fn compute_proof_of_knowledge<C: Ciphersuite, R: RngCore + CryptoRng>
let c_i = challenge::<C>(identifier, &commitment.verifying_key()?, &R_i)
.ok_or(Error::DKGNotSupported)?;
let a_i0 = *coefficients
.get(0)
.first()
.expect("coefficients must have at least one element");
let mu_i = k + a_i0 * c_i.0;
Ok(Signature { R: R_i, z: mu_i })
@ -506,6 +506,10 @@ pub fn part3<C: Ciphersuite>(
commitment: commitment.clone(),
};
if secret_share.commitment.0.len() != round2_secret_package.min_signers {
return Err(Error::IncorrectNumberOfCommitments);
}
// Verify the share. We don't need the result.
let _ = secret_share.verify()?;

View File

@ -360,7 +360,7 @@ fn check_aggregate_invalid_share_identifier_for_verifying_shares<C: Ciphersuite
.expect_err("should not work");
}
/// Test FROST signing with trusted dealer with a Ciphersuite.
/// Test FROST signing with DKG with a Ciphersuite.
pub fn check_sign_with_dkg<C: Ciphersuite + PartialEq, R: RngCore + CryptoRng>(
mut rng: R,
) -> (Vec<u8>, Signature<C>, VerifyingKey<C>)