Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings #578

Merged
merged 3 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion book/src/dev/developer-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
Test coverage checks are performed in the pipeline. This is cofigured here: `.github/workflows/coverage.yaml`
To run these locally:
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`)
4 changes: 2 additions & 2 deletions frost-core/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -894,12 +894,12 @@ pub(crate) fn generate_secret_shares<C: Ciphersuite>(
}

for id in identifiers {
let value = evaluate_polynomial(*id, &coefficients);
let signing_share = SigningShare::from_coefficients(&coefficients, *id);

secret_shares.push(SecretShare {
header: Header::default(),
identifier: *id,
signing_share: SigningShare(value),
signing_share,
commitment: commitment.clone(),
});
}
Expand Down
4 changes: 2 additions & 2 deletions frost-core/src/keys/dkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,13 @@ pub fn part2<C: Ciphersuite>(
// > 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)),
// > 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(
ell,
round2::Package {
header: Header::default(),
signing_share: SigningShare(value),
signing_share,
},
);
}
Expand Down
19 changes: 4 additions & 15 deletions frost-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,6 @@ impl<C> BindingFactor<C>
where
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.
pub fn serialize(&self) -> <<C::Group as Group>::Field as Field>::Serialization {
<<C::Group as Group>::Field>::serialize(&self.0)
Expand Down Expand Up @@ -227,11 +218,6 @@ where
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.
pub fn get(&self, key: &Identifier<C>) -> Option<&BindingFactor<C>> {
self.0.get(key)
Expand Down Expand Up @@ -273,8 +259,11 @@ where

fn from_hex<T: AsRef<[u8]>>(hex: T) -> Result<Self, Self::Error> {
let v: Vec<u8> = FromHex::from_hex(hex).map_err(|_| "invalid hex")?;

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"),
}
}
Expand Down
2 changes: 1 addition & 1 deletion frost-core/src/tests/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ pub fn check_sign_with_test_vectors<C: Ciphersuite>(json_vectors: &Value) {
let binding_factor_list: frost::BindingFactorList<C> =
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]);
}

Expand Down