From b533e845bef58be23dc40fd459c67542885112d3 Mon Sep 17 00:00:00 2001 From: Iraklis Leontiadis <120665504+leontiadZen@users.noreply.github.com> Date: Wed, 5 Jul 2023 21:25:03 +0300 Subject: [PATCH] changes (#212) --- benches/multi_party_ecdsa/gg18/keygen.rs | 4 ++-- examples/common.rs | 2 +- examples/gg18_sign_client.rs | 4 ++-- src/protocols/multi_party_ecdsa/gg_2018/test.rs | 4 ++-- src/protocols/multi_party_ecdsa/gg_2020/blame.rs | 2 +- src/protocols/multi_party_ecdsa/gg_2020/party_i.rs | 2 +- .../gg_2020/state_machine/sign/rounds.rs | 4 ++-- src/protocols/two_party_ecdsa/lindell_2017/party_one.rs | 4 ++-- src/utilities/mta/range_proofs.rs | 8 ++++---- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/benches/multi_party_ecdsa/gg18/keygen.rs b/benches/multi_party_ecdsa/gg18/keygen.rs index 5c4b0c7a..d4d5d768 100644 --- a/benches/multi_party_ecdsa/gg18/keygen.rs +++ b/benches/multi_party_ecdsa/gg18/keygen.rs @@ -65,7 +65,7 @@ mod bench { .expect("invalid key"); vss_scheme_vec.push(vss_scheme); secret_shares_vec.push(secret_shares); - index_vec.push(index as u16); + index_vec.push(index); } let vss_scheme_for_test = vss_scheme_vec.clone(); @@ -89,7 +89,7 @@ mod bench { &y_vec, &party_shares[i], &vss_scheme_vec, - (&index_vec[i] + 1).into(), + (&index_vec[i] + 1), ) .expect("invalid vss"); shared_keys_vec.push(shared_keys); diff --git a/examples/common.rs b/examples/common.rs index 1fbacbc3..dbb4fa44 100644 --- a/examples/common.rs +++ b/examples/common.rs @@ -63,7 +63,7 @@ pub fn aes_encrypt(key: &[u8], plaintext: &[u8]) -> AEAD { .expect("encryption failure!"); AEAD { - ciphertext: ciphertext, + ciphertext, tag: nonce.to_vec(), } } diff --git a/examples/gg18_sign_client.rs b/examples/gg18_sign_client.rs index 86e7ed2a..b02b990f 100644 --- a/examples/gg18_sign_client.rs +++ b/examples/gg18_sign_client.rs @@ -33,7 +33,7 @@ fn main() { if env::args().nth(3).is_none() { panic!("too few arguments") } - let message_str = env::args().nth(3).unwrap_or_else(|| "".to_string()); + let message_str = env::args().nth(3).unwrap_or_default(); let message = match hex::decode(message_str.clone()) { Ok(x) => x, Err(_e) => message_str.as_bytes().to_vec(), @@ -502,7 +502,7 @@ fn main() { // check sig against secp256k1 check_sig(&sig.r, &sig.s, &message_bn, &y_sum); - fs::write("signature".to_string(), sign_json).expect("Unable to save !"); + fs::write("signature", sign_json).expect("Unable to save !"); } fn format_vec_from_reads<'a, T: serde::Deserialize<'a> + Clone>( diff --git a/src/protocols/multi_party_ecdsa/gg_2018/test.rs b/src/protocols/multi_party_ecdsa/gg_2018/test.rs index a3451a4e..44a25e43 100644 --- a/src/protocols/multi_party_ecdsa/gg_2018/test.rs +++ b/src/protocols/multi_party_ecdsa/gg_2018/test.rs @@ -100,7 +100,7 @@ fn keygen_t_n_parties( for (vss_scheme, secret_shares, index) in vss_result { vss_scheme_vec.push(vss_scheme); secret_shares_vec.push(secret_shares); // cannot unzip - index_vec.push(index as u16); + index_vec.push(index); } let vss_scheme_for_test = vss_scheme_vec.clone(); @@ -122,7 +122,7 @@ fn keygen_t_n_parties( &y_vec, &party_shares[i], &vss_scheme_vec, - (&index_vec[i] + 1).into(), + (&index_vec[i] + 1), ) .expect("invalid vss"); shared_keys_vec.push(shared_keys); diff --git a/src/protocols/multi_party_ecdsa/gg_2020/blame.rs b/src/protocols/multi_party_ecdsa/gg_2020/blame.rs index 929a43d8..7b9dc171 100644 --- a/src/protocols/multi_party_ecdsa/gg_2020/blame.rs +++ b/src/protocols/multi_party_ecdsa/gg_2020/blame.rs @@ -378,7 +378,7 @@ impl GlobalStatePhase6 { .map(|i| { let g_wi_ki = &self.g_w_vec[i] * &self.k_vec[i]; let sum = self.miu_vec[i].iter().fold(g_wi_ki, |acc, x| { - acc + (Point::generator() * &Scalar::::from(&*x)) + acc + (Point::generator() * &Scalar::::from(x)) }); sum }) diff --git a/src/protocols/multi_party_ecdsa/gg_2020/party_i.rs b/src/protocols/multi_party_ecdsa/gg_2020/party_i.rs index 6fd6d441..75061c87 100644 --- a/src/protocols/multi_party_ecdsa/gg_2020/party_i.rs +++ b/src/protocols/multi_party_ecdsa/gg_2020/party_i.rs @@ -374,7 +374,7 @@ impl Keys { let mut global_coefficients = head[0].commitments.clone(); for vss in tail { for (i, coefficient_commitment) in vss.commitments.iter().enumerate() { - global_coefficients[i] = &global_coefficients[i] + &*coefficient_commitment; + global_coefficients[i] = &global_coefficients[i] + coefficient_commitment; } } diff --git a/src/protocols/multi_party_ecdsa/gg_2020/state_machine/sign/rounds.rs b/src/protocols/multi_party_ecdsa/gg_2020/state_machine/sign/rounds.rs index fb07c487..4fe340f6 100644 --- a/src/protocols/multi_party_ecdsa/gg_2020/state_machine/sign/rounds.rs +++ b/src/protocols/multi_party_ecdsa/gg_2020/state_machine/sign/rounds.rs @@ -447,7 +447,7 @@ impl Round4 { &self.bc_vec, usize::from(self.i - 1), ) - .map_err(|e| Error::Round5(e))?; + .map_err(Error::Round5)?; let R_dash = &R * &self.sign_keys.k_i; @@ -554,7 +554,7 @@ impl Round5 { &l_s, i, ) - .map_err(|e| Error::Round5(e))?; + .map_err(Error::Round5)?; } LocalSignature::phase5_check_R_dash_sum(&r_dash_vec).map_err(|e| { Error::Round5(ErrorType { diff --git a/src/protocols/two_party_ecdsa/lindell_2017/party_one.rs b/src/protocols/two_party_ecdsa/lindell_2017/party_one.rs index 072d32f1..ed8a51ad 100644 --- a/src/protocols/two_party_ecdsa/lindell_2017/party_one.rs +++ b/src/protocols/two_party_ecdsa/lindell_2017/party_one.rs @@ -257,7 +257,7 @@ impl Party1Private { ) { let (ek_new, dk_new) = Paillier::keypair().keys(); let randomness = Randomness::sample(&ek_new); - let factor_fe = Scalar::::from(&*factor); + let factor_fe = Scalar::::from(factor); let x1_new = &party_one_private.x1 * factor_fe; let c_key_new = Paillier::encrypt_with_chosen_randomness( &ek_new, @@ -576,7 +576,7 @@ pub fn verify( let e_fe: Scalar = Scalar::::from(&message.mod_floor(Scalar::::group_order())); let u1 = Point::generator() * e_fe * &s_inv_fe; - let u2 = &*pubkey * rx_fe * &s_inv_fe; + let u2 = pubkey * rx_fe * &s_inv_fe; // second condition is against malleability let rx_bytes = &BigInt::to_bytes(&signature.r)[..]; diff --git a/src/utilities/mta/range_proofs.rs b/src/utilities/mta/range_proofs.rs index 4610a57f..456edaa7 100644 --- a/src/utilities/mta/range_proofs.rs +++ b/src/utilities/mta/range_proofs.rs @@ -669,7 +669,7 @@ pub(crate) mod tests { let (bob_proof, _) = BobProof::generate( &encrypted_a, - &mta_out.0.clone().into_owned(), + &mta_out.0.clone(), &b, &beta_prim, alice_public_key, @@ -679,7 +679,7 @@ pub(crate) mod tests { ); assert!(bob_proof.verify( &encrypted_a, - &mta_out.0.clone().into_owned(), + &mta_out.0.clone(), alice_public_key, &dlog_statement, None @@ -690,7 +690,7 @@ pub(crate) mod tests { let X = ec_gen * &b; let bob_proof = generate( &encrypted_a, - &mta_out.0.clone().into_owned(), + &mta_out.0.clone(), &b, &beta_prim, alice_public_key, @@ -699,7 +699,7 @@ pub(crate) mod tests { ); assert!(bob_proof.verify( &encrypted_a, - &mta_out.0.clone().into_owned(), + &mta_out.0.clone(), alice_public_key, &dlog_statement, &X