From b5e6da88200c60bbffc420c891f2c50b710cacaf Mon Sep 17 00:00:00 2001 From: Conrado Gouvea Date: Mon, 9 Jan 2023 18:23:59 -0300 Subject: [PATCH] clippy fixes (#212) --- frost-core/src/frost/keys.rs | 2 +- frost-core/src/tests.rs | 2 +- frost-core/src/tests/vectors.rs | 5 +---- frost-ed25519/tests/proptests.rs | 4 ++-- frost-ed448/tests/proptests.rs | 4 ++-- frost-p256/tests/proptests.rs | 4 ++-- frost-rerandomized/src/tests.rs | 2 +- frost-ristretto255/tests/proptests.rs | 4 ++-- frost-secp256k1/tests/proptests.rs | 4 ++-- 9 files changed, 14 insertions(+), 17 deletions(-) diff --git a/frost-core/src/frost/keys.rs b/frost-core/src/frost/keys.rs index 5659a17..f2c42c1 100644 --- a/frost-core/src/frost/keys.rs +++ b/frost-core/src/frost/keys.rs @@ -544,7 +544,7 @@ pub(crate) fn generate_secret_shares( let (coefficients, commitment) = generate_secret_polynomial(secret, max_signers, min_signers, coefficients)?; - for idx in 1..=max_signers as u16 { + for idx in 1..=max_signers { let id = Identifier::::try_from(idx)?; let value = evaluate_polynomial(id, &coefficients); diff --git a/frost-core/src/tests.rs b/frost-core/src/tests.rs index 6e53e00..057a7e5 100644 --- a/frost-core/src/tests.rs +++ b/frost-core/src/tests.rs @@ -73,7 +73,7 @@ fn check_sign( // Round 1: generating nonces and signing commitments for each participant //////////////////////////////////////////////////////////////////////////// - for participant_index in 1..(min_signers as u16 + 1) { + for participant_index in 1..(min_signers + 1) { let participant_identifier = participant_index.try_into().expect("should be nonzero"); // Generate one (1) nonce and one SigningCommitments instance for each // participant, up to _min_signers_. diff --git a/frost-core/src/tests/vectors.rs b/frost-core/src/tests/vectors.rs index b2fb6dd..67decbf 100644 --- a/frost-core/src/tests/vectors.rs +++ b/frost-core/src/tests/vectors.rs @@ -273,10 +273,7 @@ pub fn check_sign_with_test_vectors(json_vectors: &Value) { // Round 2: each participant generates their signature share ///////////////////////////////////////////////////////////////////////////// - let signer_commitments_vec = signer_commitments - .into_iter() - .map(|(_, signing_commitments)| signing_commitments) - .collect(); + let signer_commitments_vec = signer_commitments.into_values().collect(); let signing_package = frost::SigningPackage::new(signer_commitments_vec, message_bytes); diff --git a/frost-ed25519/tests/proptests.rs b/frost-ed25519/tests/proptests.rs index 50af958..a5f49c6 100644 --- a/frost-ed25519/tests/proptests.rs +++ b/frost-ed25519/tests/proptests.rs @@ -15,11 +15,11 @@ proptest! { // Use a deterministic RNG so that test failures can be reproduced. // Seeding with 64 bits of entropy is INSECURE and this code should // not be copied outside of this test! - let mut rng = ChaChaRng::from_seed(rng_seed); + let rng = ChaChaRng::from_seed(rng_seed); // Create a test case for each signature type. let msg = b"test message for proptests"; - let mut sig = SignatureCase::::new(&mut rng, msg.to_vec()); + let mut sig = SignatureCase::::new(rng, msg.to_vec()); // Apply tweaks to each case. for t in &tweaks { diff --git a/frost-ed448/tests/proptests.rs b/frost-ed448/tests/proptests.rs index 6a10ba5..4f03ce2 100644 --- a/frost-ed448/tests/proptests.rs +++ b/frost-ed448/tests/proptests.rs @@ -15,11 +15,11 @@ proptest! { // Use a deterministic RNG so that test failures can be reproduced. // Seeding with 64 bits of entropy is INSECURE and this code should // not be copied outside of this test! - let mut rng = ChaChaRng::from_seed(rng_seed); + let rng = ChaChaRng::from_seed(rng_seed); // Create a test case for each signature type. let msg = b"test message for proptests"; - let mut sig = SignatureCase::::new(&mut rng, msg.to_vec()); + let mut sig = SignatureCase::::new(rng, msg.to_vec()); // Apply tweaks to each case. for t in &tweaks { diff --git a/frost-p256/tests/proptests.rs b/frost-p256/tests/proptests.rs index 55e9583..3214742 100644 --- a/frost-p256/tests/proptests.rs +++ b/frost-p256/tests/proptests.rs @@ -15,11 +15,11 @@ proptest! { // Use a deterministic RNG so that test failures can be reproduced. // Seeding with 64 bits of entropy is INSECURE and this code should // not be copied outside of this test! - let mut rng = ChaChaRng::from_seed(rng_seed); + let rng = ChaChaRng::from_seed(rng_seed); // Create a test case for each signature type. let msg = b"test message for proptests"; - let mut sig = SignatureCase::::new(&mut rng, msg.to_vec()); + let mut sig = SignatureCase::::new(rng, msg.to_vec()); // Apply tweaks to each case. for t in &tweaks { diff --git a/frost-rerandomized/src/tests.rs b/frost-rerandomized/src/tests.rs index 521bb47..a08ad41 100644 --- a/frost-rerandomized/src/tests.rs +++ b/frost-rerandomized/src/tests.rs @@ -42,7 +42,7 @@ pub fn check_randomized_sign_with_dealer // Round 1: generating nonces and signing commitments for each participant //////////////////////////////////////////////////////////////////////////// - for participant_index in 1..(min_signers as u16 + 1) { + for participant_index in 1..(min_signers + 1) { let participant_identifier = participant_index.try_into().expect("should be nonzero"); // Generate one (1) nonce and one SigningCommitments instance for each // participant, up to _min_signers_. diff --git a/frost-ristretto255/tests/proptests.rs b/frost-ristretto255/tests/proptests.rs index 8371531..a92817a 100644 --- a/frost-ristretto255/tests/proptests.rs +++ b/frost-ristretto255/tests/proptests.rs @@ -15,11 +15,11 @@ proptest! { // Use a deterministic RNG so that test failures can be reproduced. // Seeding with 64 bits of entropy is INSECURE and this code should // not be copied outside of this test! - let mut rng = ChaChaRng::from_seed(rng_seed); + let rng = ChaChaRng::from_seed(rng_seed); // Create a test case for each signature type. let msg = b"test message for proptests"; - let mut sig = SignatureCase::::new(&mut rng, msg.to_vec()); + let mut sig = SignatureCase::::new(rng, msg.to_vec()); // Apply tweaks to each case. for t in &tweaks { diff --git a/frost-secp256k1/tests/proptests.rs b/frost-secp256k1/tests/proptests.rs index 0382efc..c280b91 100644 --- a/frost-secp256k1/tests/proptests.rs +++ b/frost-secp256k1/tests/proptests.rs @@ -15,11 +15,11 @@ proptest! { // Use a deterministic RNG so that test failures can be reproduced. // Seeding with 64 bits of entropy is INSECURE and this code should // not be copied outside of this test! - let mut rng = ChaChaRng::from_seed(rng_seed); + let rng = ChaChaRng::from_seed(rng_seed); // Create a test case for each signature type. let msg = b"test message for proptests"; - let mut sig = SignatureCase::::new(&mut rng, msg.to_vec()); + let mut sig = SignatureCase::::new(rng, msg.to_vec()); // Apply tweaks to each case. for t in &tweaks {