Fix warnings (#578)
* Use from_coefficients() instead of evaluate_polynomial() when computing a signing_share (#576) * Refactor BindingFactor::deserialize into from_hex as it's only used for testing (#576) * Remove BindingFactorList::iter() and use directly in vector test (#576)
This commit is contained in:
parent
99866a7902
commit
036b0ce3fe
|
@ -11,4 +11,4 @@
|
||||||
Test coverage checks are performed in the pipeline. This is cofigured here: `.github/workflows/coverage.yaml`
|
Test coverage checks are performed in the pipeline. This is cofigured here: `.github/workflows/coverage.yaml`
|
||||||
To run these locally:
|
To run these locally:
|
||||||
1. Install coverage tool by running `cargo install cargo-llvm-cov`
|
1. Install coverage tool by running `cargo install cargo-llvm-cov`
|
||||||
2. Run `cargo llvm-cov --ignore-filename-regex '.*(tests).*|benches.rs|gencode|helpers.rs` (you may be asked if you want to install `llvm-tools-preview`, if so type `Y`)
|
2. Run `cargo llvm-cov --ignore-filename-regex '.*(tests).*|benches.rs|gencode|helpers.rs'` (you may be asked if you want to install `llvm-tools-preview`, if so type `Y`)
|
||||||
|
|
|
@ -894,12 +894,12 @@ pub(crate) fn generate_secret_shares<C: Ciphersuite>(
|
||||||
}
|
}
|
||||||
|
|
||||||
for id in identifiers {
|
for id in identifiers {
|
||||||
let value = evaluate_polynomial(*id, &coefficients);
|
let signing_share = SigningShare::from_coefficients(&coefficients, *id);
|
||||||
|
|
||||||
secret_shares.push(SecretShare {
|
secret_shares.push(SecretShare {
|
||||||
header: Header::default(),
|
header: Header::default(),
|
||||||
identifier: *id,
|
identifier: *id,
|
||||||
signing_share: SigningShare(value),
|
signing_share,
|
||||||
commitment: commitment.clone(),
|
commitment: commitment.clone(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -421,13 +421,13 @@ pub fn part2<C: Ciphersuite>(
|
||||||
// > Each P_i securely sends to each other participant P_ℓ a secret share (ℓ, f_i(ℓ)),
|
// > Each P_i securely sends to each other participant P_ℓ a secret share (ℓ, f_i(ℓ)),
|
||||||
// > deleting f_i and each share afterward except for (i, f_i(i)),
|
// > deleting f_i and each share afterward except for (i, f_i(i)),
|
||||||
// > which they keep for themselves.
|
// > which they keep for themselves.
|
||||||
let value = evaluate_polynomial(ell, &secret_package.coefficients);
|
let signing_share = SigningShare::from_coefficients(&secret_package.coefficients, ell);
|
||||||
|
|
||||||
round2_packages.insert(
|
round2_packages.insert(
|
||||||
ell,
|
ell,
|
||||||
round2::Package {
|
round2::Package {
|
||||||
header: Header::default(),
|
header: Header::default(),
|
||||||
signing_share: SigningShare(value),
|
signing_share,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,15 +185,6 @@ impl<C> BindingFactor<C>
|
||||||
where
|
where
|
||||||
C: Ciphersuite,
|
C: Ciphersuite,
|
||||||
{
|
{
|
||||||
/// Deserializes [`BindingFactor`] from bytes.
|
|
||||||
pub fn deserialize(
|
|
||||||
bytes: <<C::Group as Group>::Field as Field>::Serialization,
|
|
||||||
) -> Result<Self, Error<C>> {
|
|
||||||
<<C::Group as Group>::Field>::deserialize(&bytes)
|
|
||||||
.map(|scalar| Self(scalar))
|
|
||||||
.map_err(|e| e.into())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Serializes [`BindingFactor`] to bytes.
|
/// Serializes [`BindingFactor`] to bytes.
|
||||||
pub fn serialize(&self) -> <<C::Group as Group>::Field as Field>::Serialization {
|
pub fn serialize(&self) -> <<C::Group as Group>::Field as Field>::Serialization {
|
||||||
<<C::Group as Group>::Field>::serialize(&self.0)
|
<<C::Group as Group>::Field>::serialize(&self.0)
|
||||||
|
@ -227,11 +218,6 @@ where
|
||||||
Self(binding_factors)
|
Self(binding_factors)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return iterator through all factors.
|
|
||||||
pub fn iter(&self) -> impl Iterator<Item = (&Identifier<C>, &BindingFactor<C>)> {
|
|
||||||
self.0.iter()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the [`BindingFactor`] for the given identifier, or None if not found.
|
/// Get the [`BindingFactor`] for the given identifier, or None if not found.
|
||||||
pub fn get(&self, key: &Identifier<C>) -> Option<&BindingFactor<C>> {
|
pub fn get(&self, key: &Identifier<C>) -> Option<&BindingFactor<C>> {
|
||||||
self.0.get(key)
|
self.0.get(key)
|
||||||
|
@ -273,8 +259,11 @@ where
|
||||||
|
|
||||||
fn from_hex<T: AsRef<[u8]>>(hex: T) -> Result<Self, Self::Error> {
|
fn from_hex<T: AsRef<[u8]>>(hex: T) -> Result<Self, Self::Error> {
|
||||||
let v: Vec<u8> = FromHex::from_hex(hex).map_err(|_| "invalid hex")?;
|
let v: Vec<u8> = FromHex::from_hex(hex).map_err(|_| "invalid hex")?;
|
||||||
|
|
||||||
match v.try_into() {
|
match v.try_into() {
|
||||||
Ok(bytes) => Self::deserialize(bytes).map_err(|_| "malformed scalar encoding"),
|
Ok(bytes) => <<C::Group as Group>::Field>::deserialize(&bytes)
|
||||||
|
.map(|scalar| Self(scalar))
|
||||||
|
.map_err(|_| "malformed scalar encoding"),
|
||||||
Err(_) => Err("malformed scalar encoding"),
|
Err(_) => Err("malformed scalar encoding"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,7 +271,7 @@ pub fn check_sign_with_test_vectors<C: Ciphersuite>(json_vectors: &Value) {
|
||||||
let binding_factor_list: frost::BindingFactorList<C> =
|
let binding_factor_list: frost::BindingFactorList<C> =
|
||||||
compute_binding_factor_list(&signing_package, &verifying_key, &[]);
|
compute_binding_factor_list(&signing_package, &verifying_key, &[]);
|
||||||
|
|
||||||
for (identifier, binding_factor) in binding_factor_list.iter() {
|
for (identifier, binding_factor) in binding_factor_list.0.iter() {
|
||||||
assert_eq!(*binding_factor, binding_factors[identifier]);
|
assert_eq!(*binding_factor, binding_factors[identifier]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue