From 996f4afaf7f8fa72b1a9b972bf5acbfa50516c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Fri, 3 May 2024 19:21:55 +0100 Subject: [PATCH 1/3] [feature]: expose coconut methods for aggregation without verification --- common/credentials-interface/src/lib.rs | 4 +- .../src/coconut/bandwidth/issuance.rs | 11 +-- common/nymcoconut/benches/benchmarks.rs | 10 +-- common/nymcoconut/src/lib.rs | 7 ++ common/nymcoconut/src/scheme/aggregation.rs | 76 +++++++++++++------ common/nymcoconut/src/scheme/issuance.rs | 7 +- common/nymcoconut/src/scheme/keygen.rs | 36 +++++++-- common/nymcoconut/src/scheme/mod.rs | 38 +++++++--- common/nymcoconut/src/scheme/setup.rs | 1 + common/nymcoconut/src/scheme/verification.rs | 1 - common/nymcoconut/src/tests/helpers.rs | 8 +- 11 files changed, 139 insertions(+), 60 deletions(-) diff --git a/common/credentials-interface/src/lib.rs b/common/credentials-interface/src/lib.rs index 277dcbe5a5..7edc1d6904 100644 --- a/common/credentials-interface/src/lib.rs +++ b/common/credentials-interface/src/lib.rs @@ -8,8 +8,8 @@ use std::str::FromStr; use thiserror::Error; pub use nym_coconut::{ - aggregate_signature_shares, aggregate_verification_keys, blind_sign, hash_to_scalar, keygen, - prepare_blind_sign, prove_bandwidth_credential, verify_credential, Attribute, Base58, + aggregate_signature_shares_and_verify, aggregate_verification_keys, blind_sign, hash_to_scalar, + keygen, prepare_blind_sign, prove_bandwidth_credential, verify_credential, Attribute, Base58, BlindSignRequest, BlindedSerialNumber, BlindedSignature, Bytable, CoconutError, KeyPair, Parameters, PrivateAttribute, PublicAttribute, SecretKey, Signature, SignatureShare, VerificationKey, VerifyCredentialRequest, diff --git a/common/credentials/src/coconut/bandwidth/issuance.rs b/common/credentials/src/coconut/bandwidth/issuance.rs index 53c89a300b..396f25c8cc 100644 --- a/common/credentials/src/coconut/bandwidth/issuance.rs +++ b/common/credentials/src/coconut/bandwidth/issuance.rs @@ -10,18 +10,19 @@ use crate::coconut::bandwidth::{ use crate::coconut::utils::scalar_serde_helper; use crate::error::Error; use nym_credentials_interface::{ - aggregate_signature_shares, hash_to_scalar, prepare_blind_sign, Attribute, BlindedSerialNumber, - BlindedSignature, Parameters, PrivateAttribute, PublicAttribute, Signature, SignatureShare, - VerificationKey, + aggregate_signature_shares_and_verify, hash_to_scalar, prepare_blind_sign, Attribute, + BlindedSerialNumber, BlindedSignature, Parameters, PrivateAttribute, PublicAttribute, + Signature, SignatureShare, VerificationKey, }; use nym_crypto::asymmetric::{encryption, identity}; use nym_validator_client::nym_api::EpochId; -use nym_validator_client::nyxd::{Coin, Hash}; use nym_validator_client::signing::AccountData; use serde::{Deserialize, Serialize}; use time::OffsetDateTime; use zeroize::{Zeroize, ZeroizeOnDrop}; +pub use nym_validator_client::nyxd::{Coin, Hash}; + #[derive(Zeroize, ZeroizeOnDrop, Serialize, Deserialize)] pub enum BandwidthCredentialIssuanceDataVariant { Voucher(BandwidthVoucherIssuanceData), @@ -279,7 +280,7 @@ impl IssuanceBandwidthCredential { attributes.extend_from_slice(&private_attributes); attributes.extend_from_slice(&public_attributes); - aggregate_signature_shares(params, verification_key, &attributes, shares) + aggregate_signature_shares_and_verify(params, verification_key, &attributes, shares) .map_err(Error::SignatureAggregationError) } diff --git a/common/nymcoconut/benches/benchmarks.rs b/common/nymcoconut/benches/benchmarks.rs index 966e676f42..e550791969 100644 --- a/common/nymcoconut/benches/benchmarks.rs +++ b/common/nymcoconut/benches/benchmarks.rs @@ -6,10 +6,10 @@ use criterion::{criterion_group, criterion_main, Criterion}; use ff::Field; use group::{Curve, Group}; use nym_coconut::{ - aggregate_signature_shares, aggregate_verification_keys, blind_sign, prepare_blind_sign, - prove_bandwidth_credential, random_scalars_refs, setup, ttp_keygen, verify_credential, - verify_partial_blind_signature, Attribute, BlindedSignature, Parameters, Signature, - SignatureShare, VerificationKey, + aggregate_signature_shares_and_verify, aggregate_verification_keys, blind_sign, + prepare_blind_sign, prove_bandwidth_credential, random_scalars_refs, setup, ttp_keygen, + verify_credential, verify_partial_blind_signature, Attribute, BlindedSignature, Parameters, + Signature, SignatureShare, VerificationKey, }; use rand::seq::SliceRandom; use std::ops::Neg; @@ -99,7 +99,7 @@ fn unblind_and_aggregate( let mut attributes = vec![]; attributes.extend_from_slice(private_attributes); attributes.extend_from_slice(public_attributes); - aggregate_signature_shares( + aggregate_signature_shares_and_verify( params, verification_key, &attributes, diff --git a/common/nymcoconut/src/lib.rs b/common/nymcoconut/src/lib.rs index e2a3138b3a..3eed2bf88c 100644 --- a/common/nymcoconut/src/lib.rs +++ b/common/nymcoconut/src/lib.rs @@ -4,14 +4,18 @@ #![warn(clippy::expect_used)] #![warn(clippy::unwrap_used)] +pub use bls12_381::Scalar; pub use elgamal::elgamal_keygen; pub use elgamal::ElGamalKeyPair; pub use elgamal::PublicKey; pub use error::CoconutError; +pub use scheme::aggregation::aggregate_key_shares; pub use scheme::aggregation::aggregate_signature_shares; +pub use scheme::aggregation::aggregate_signature_shares_and_verify; pub use scheme::aggregation::aggregate_verification_keys; pub use scheme::issuance::blind_sign; pub use scheme::issuance::prepare_blind_sign; +pub use scheme::issuance::sign; pub use scheme::issuance::verify_partial_blind_signature; pub use scheme::issuance::BlindSignRequest; pub use scheme::keygen::keygen; @@ -19,16 +23,19 @@ pub use scheme::keygen::ttp_keygen; pub use scheme::keygen::KeyPair; pub use scheme::keygen::SecretKey; pub use scheme::keygen::VerificationKey; +pub use scheme::keygen::VerificationKeyShare; pub use scheme::setup::setup; pub use scheme::setup::Parameters; pub use scheme::verification::check_vk_pairing; pub use scheme::verification::prove_bandwidth_credential; +pub use scheme::verification::verify; pub use scheme::verification::verify_credential; pub use scheme::verification::BlindedSerialNumber; pub use scheme::verification::VerifyCredentialRequest; pub use scheme::BlindedSignature; pub use scheme::Signature; pub use scheme::SignatureShare; +pub use scheme::SignerIndex; pub use traits::Base58; pub use traits::Bytable; pub use utils::hash_to_scalar; diff --git a/common/nymcoconut/src/scheme/aggregation.rs b/common/nymcoconut/src/scheme/aggregation.rs index 12f0b0cfad..c6e71d7c03 100644 --- a/common/nymcoconut/src/scheme/aggregation.rs +++ b/common/nymcoconut/src/scheme/aggregation.rs @@ -12,7 +12,7 @@ use crate::error::{CoconutError, Result}; use crate::scheme::verification::check_bilinear_pairing; use crate::scheme::{PartialSignature, Signature, SignatureShare, SignerIndex, VerificationKey}; use crate::utils::perform_lagrangian_interpolation_at_origin; -use crate::{Attribute, Parameters}; +use crate::{Attribute, Parameters, VerificationKeyShare}; pub(crate) trait Aggregatable: Sized { fn aggregate(aggregatable: &[Self], indices: Option<&[SignerIndex]>) -> Result; @@ -80,7 +80,23 @@ pub fn aggregate_verification_keys( Aggregatable::aggregate(keys, indices) } +pub fn aggregate_key_shares(shares: &[VerificationKeyShare]) -> Result { + let (keys, indices): (Vec<_>, Vec<_>) = shares + .iter() + .map(|share| (share.key.clone(), share.index)) + .unzip(); + + aggregate_verification_keys(&keys, Some(&indices)) +} + pub fn aggregate_signatures( + signatures: &[PartialSignature], + indices: Option<&[SignerIndex]>, +) -> Result { + Aggregatable::aggregate(signatures, indices) +} + +pub fn aggregate_signatures_and_verify( params: &Parameters, verification_key: &VerificationKey, attributes: &[&Attribute], @@ -88,11 +104,7 @@ pub fn aggregate_signatures( indices: Option<&[SignerIndex]>, ) -> Result { // aggregate the signature - - let signature = match Aggregatable::aggregate(signatures, indices) { - Ok(res) => res, - Err(err) => return Err(err), - }; + let signature = aggregate_signatures(signatures, indices)?; // Verify the signature let alpha = verification_key.alpha; @@ -116,7 +128,16 @@ pub fn aggregate_signatures( Ok(signature) } -pub fn aggregate_signature_shares( +pub fn aggregate_signature_shares(shares: &[SignatureShare]) -> Result { + let (signatures, indices): (Vec<_>, Vec<_>) = shares + .iter() + .map(|share| (*share.signature(), share.index())) + .unzip(); + + aggregate_signatures(&signatures, Some(&indices)) +} + +pub fn aggregate_signature_shares_and_verify( params: &Parameters, verification_key: &VerificationKey, attributes: &[&Attribute], @@ -127,7 +148,7 @@ pub fn aggregate_signature_shares( .map(|share| (*share.signature(), share.index())) .unzip(); - aggregate_signatures( + aggregate_signatures_and_verify( params, verification_key, attributes, @@ -232,7 +253,7 @@ mod tests { // aggregating (any) threshold works let aggr_vk_1 = aggregate_verification_keys(&vks[..3], Some(&[1, 2, 3])).unwrap(); - let aggr_sig1 = aggregate_signatures( + let aggr_sig1 = aggregate_signatures_and_verify( ¶ms, &aggr_vk_1, &attributes, @@ -242,7 +263,7 @@ mod tests { .unwrap(); let aggr_vk_2 = aggregate_verification_keys(&vks[2..], Some(&[3, 4, 5])).unwrap(); - let aggr_sig2 = aggregate_signatures( + let aggr_sig2 = aggregate_signatures_and_verify( ¶ms, &aggr_vk_1, &attributes, @@ -258,7 +279,7 @@ mod tests { // aggregating threshold+1 works let aggr_vk_more = aggregate_verification_keys(&vks[1..], Some(&[2, 3, 4, 5])).unwrap(); - let aggr_more = aggregate_signatures( + let aggr_more = aggregate_signatures_and_verify( ¶ms, &aggr_vk_more, &attributes, @@ -270,7 +291,7 @@ mod tests { // aggregating all let aggr_vk_all = aggregate_verification_keys(&vks, Some(&[1, 2, 3, 4, 5])).unwrap(); - let aggr_all = aggregate_signatures( + let aggr_all = aggregate_signatures_and_verify( ¶ms, &aggr_vk_all, &attributes, @@ -282,7 +303,7 @@ mod tests { // not taking enough points (threshold was 3) should fail let aggr_vk_not_enough = aggregate_verification_keys(&vks[..2], Some(&[1, 2])).unwrap(); - let aggr_not_enough = aggregate_signatures( + let aggr_not_enough = aggregate_signatures_and_verify( ¶ms, &aggr_vk_not_enough, &attributes, @@ -294,7 +315,7 @@ mod tests { // taking wrong index should fail let aggr_vk_bad = aggregate_verification_keys(&vks[2..], Some(&[1, 2, 3])).unwrap(); - assert!(aggregate_signatures( + assert!(aggregate_signatures_and_verify( ¶ms, &aggr_vk_bad, &attributes, @@ -330,9 +351,14 @@ mod tests { .unzip(); let aggr_vk_all = aggregate_verification_keys(&vks, None).unwrap(); - assert!( - aggregate_signatures(¶ms, &aggr_vk_all, &attributes, &signatures, None).is_err() - ); + assert!(aggregate_signatures_and_verify( + ¶ms, + &aggr_vk_all, + &attributes, + &signatures, + None + ) + .is_err()); } #[test] @@ -352,11 +378,15 @@ mod tests { .unzip(); let aggr_vk_all = aggregate_verification_keys(&vks, None).unwrap(); - assert!( - aggregate_signatures(¶ms, &aggr_vk_all, &attributes, &signatures, Some(&[])) - .is_err() - ); - assert!(aggregate_signatures( + assert!(aggregate_signatures_and_verify( + ¶ms, + &aggr_vk_all, + &attributes, + &signatures, + Some(&[]) + ) + .is_err()); + assert!(aggregate_signatures_and_verify( ¶ms, &aggr_vk_all, &attributes, @@ -383,7 +413,7 @@ mod tests { .unzip(); let aggr_vk_all = aggregate_verification_keys(&vks, None).unwrap(); - assert!(aggregate_signatures( + assert!(aggregate_signatures_and_verify( ¶ms, &aggr_vk_all, &attributes, diff --git a/common/nymcoconut/src/scheme/issuance.rs b/common/nymcoconut/src/scheme/issuance.rs index 088f691f32..1582a55e98 100644 --- a/common/nymcoconut/src/scheme/issuance.rs +++ b/common/nymcoconut/src/scheme/issuance.rs @@ -13,9 +13,8 @@ use crate::scheme::setup::Parameters; use crate::scheme::BlindedSignature; use crate::scheme::SecretKey; use crate::Attribute; -/// Creates a Coconut Signature under a given secret key on a set of public attributes only. -#[cfg(test)] use crate::Signature; + // TODO: possibly completely remove those two functions. // They only exist to have a simpler and smaller code snippets to test // basic functionalities. @@ -426,9 +425,9 @@ pub fn verify_partial_blind_signature( .into() } -#[cfg(test)] +/// Creates a Coconut Signature under a given secret key on a set of public attributes only. pub fn sign( - params: &mut Parameters, + params: &Parameters, secret_key: &SecretKey, public_attributes: &[&Attribute], ) -> Result { diff --git a/common/nymcoconut/src/scheme/keygen.rs b/common/nymcoconut/src/scheme/keygen.rs index c587ad8fd9..90891acd94 100644 --- a/common/nymcoconut/src/scheme/keygen.rs +++ b/common/nymcoconut/src/scheme/keygen.rs @@ -151,10 +151,6 @@ impl Base58 for SecretKey {} // TODO: perhaps change points to affine representation // to make verification slightly more efficient? #[derive(Debug, PartialEq, Eq, Clone)] -#[cfg_attr( - feature = "key-zeroize", - derive(zeroize::Zeroize, zeroize::ZeroizeOnDrop) -)] pub struct VerificationKey { // TODO add gen2 as per the paper or imply it from the fact library is using bls381? pub(crate) alpha: G2Projective, @@ -411,12 +407,23 @@ impl Bytable for VerificationKey { impl Base58 for VerificationKey {} +#[derive(Debug, Clone)] +pub struct VerificationKeyShare { + pub key: VerificationKey, + pub index: SignerIndex, +} + +impl From<(VerificationKey, SignerIndex)> for VerificationKeyShare { + fn from(value: (VerificationKey, SignerIndex)) -> Self { + VerificationKeyShare { + key: value.0, + index: value.1, + } + } +} + #[derive(Debug, Serialize, Deserialize)] #[cfg_attr(test, derive(PartialEq, Eq, Clone))] -#[cfg_attr( - feature = "key-zeroize", - derive(zeroize::Zeroize, zeroize::ZeroizeOnDrop) -)] pub struct KeyPair { secret_key: SecretKey, verification_key: VerificationKey, @@ -425,6 +432,12 @@ pub struct KeyPair { pub index: Option, } +impl From for (SecretKey, VerificationKey) { + fn from(value: KeyPair) -> Self { + (value.secret_key, value.verification_key) + } +} + impl PemStorableKeyPair for KeyPair { type PrivatePemKey = SecretKey; type PublicPemKey = VerificationKey; @@ -461,6 +474,13 @@ impl KeyPair { &self.verification_key } + pub fn to_verification_key_share(&self) -> Option { + self.index.map(|index| VerificationKeyShare { + key: self.verification_key.clone(), + index, + }) + } + pub fn to_bytes(&self) -> Vec { // Schema is coconutkeypair[14]|secret_key_len[8]|secret_key[secret_key_len]|verification_key_len[8]|verification_key[verification_key_len]|signer_index[8] - optional self.to_byte_vec() diff --git a/common/nymcoconut/src/scheme/mod.rs b/common/nymcoconut/src/scheme/mod.rs index 00adef8826..026afe634b 100644 --- a/common/nymcoconut/src/scheme/mod.rs +++ b/common/nymcoconut/src/scheme/mod.rs @@ -70,6 +70,11 @@ impl Signature { &self.1 } + pub fn randomise_simple(&self, params: &Parameters) -> Signature { + let r = params.random_scalar(); + Signature(self.0 * r, self.1 * r) + } + pub fn randomise(&self, params: &Parameters) -> (Signature, Scalar) { let r = params.random_scalar(); let r_prime = params.random_scalar(); @@ -191,7 +196,7 @@ impl BlindedSignature { &self, partial_verification_key: &VerificationKey, pedersen_commitments_openings: &[Scalar], - ) -> Result { + ) -> Signature { // parse the signature let h = &self.0; let c = &self.1; @@ -204,7 +209,7 @@ impl BlindedSignature { let unblinded_c = c - blinding_removers; - Ok(Signature(*h, unblinded_c)) + Signature(*h, unblinded_c) } pub fn unblind_and_verify( @@ -216,7 +221,7 @@ impl BlindedSignature { commitment_hash: &G1Projective, pedersen_commitments_openings: &[Scalar], ) -> Result { - let unblinded = self.unblind(partial_verification_key, pedersen_commitments_openings)?; + let unblinded = self.unblind(partial_verification_key, pedersen_commitments_openings); unblinded.verify( params, partial_verification_key, @@ -240,6 +245,7 @@ impl BlindedSignature { } // perhaps this should take signature by reference? we'll see how it goes +#[derive(Clone, Copy)] pub struct SignatureShare { signature: Signature, index: SignerIndex, @@ -276,7 +282,9 @@ impl SignatureShare { mod tests { use super::*; use crate::hash_to_scalar; - use crate::scheme::aggregation::{aggregate_signatures, aggregate_verification_keys}; + use crate::scheme::aggregation::{ + aggregate_signatures_and_verify, aggregate_verification_keys, + }; use crate::scheme::issuance::{blind_sign, compute_hash, prepare_blind_sign, sign}; use crate::scheme::keygen::{keygen, ttp_keygen}; use crate::scheme::verification::{prove_bandwidth_credential, verify, verify_credential}; @@ -568,9 +576,14 @@ mod tests { attributes.extend_from_slice(&public_attributes); let aggr_vk = aggregate_verification_keys(&vks[..2], Some(&[1, 2])).unwrap(); - let aggr_sig = - aggregate_signatures(¶ms, &aggr_vk, &attributes, &sigs[..2], Some(&[1, 2])) - .unwrap(); + let aggr_sig = aggregate_signatures_and_verify( + ¶ms, + &aggr_vk, + &attributes, + &sigs[..2], + Some(&[1, 2]), + ) + .unwrap(); let theta = prove_bandwidth_credential( ¶ms, @@ -590,9 +603,14 @@ mod tests { // taking different subset of keys and credentials let aggr_vk = aggregate_verification_keys(&vks[1..], Some(&[2, 3])).unwrap(); - let aggr_sig = - aggregate_signatures(¶ms, &aggr_vk, &attributes, &sigs[1..], Some(&[2, 3])) - .unwrap(); + let aggr_sig = aggregate_signatures_and_verify( + ¶ms, + &aggr_vk, + &attributes, + &sigs[1..], + Some(&[2, 3]), + ) + .unwrap(); let theta = prove_bandwidth_credential( ¶ms, diff --git a/common/nymcoconut/src/scheme/setup.rs b/common/nymcoconut/src/scheme/setup.rs index 63add88404..65c994ec8f 100644 --- a/common/nymcoconut/src/scheme/setup.rs +++ b/common/nymcoconut/src/scheme/setup.rs @@ -10,6 +10,7 @@ use crate::error::{CoconutError, Result}; use crate::utils::hash_g1; /// System-wide parameters used for the protocol +#[derive(Clone)] pub struct Parameters { /// Generator of the G1 group g1: G1Affine, diff --git a/common/nymcoconut/src/scheme/verification.rs b/common/nymcoconut/src/scheme/verification.rs index 8e4aa2d508..a1968ced47 100644 --- a/common/nymcoconut/src/scheme/verification.rs +++ b/common/nymcoconut/src/scheme/verification.rs @@ -288,7 +288,6 @@ pub fn verify_credential( } // Used in tests only -#[cfg(test)] pub fn verify( params: &Parameters, verification_key: &VerificationKey, diff --git a/common/nymcoconut/src/tests/helpers.rs b/common/nymcoconut/src/tests/helpers.rs index b8bcb6893d..f01081bbf1 100644 --- a/common/nymcoconut/src/tests/helpers.rs +++ b/common/nymcoconut/src/tests/helpers.rs @@ -75,8 +75,12 @@ pub fn theta_from_keys_and_attributes( attributes.extend_from_slice(public_attributes); // Randomize credentials and generate any cryptographic material to verify them - let signature = - aggregate_signature_shares(params, &verification_key, &attributes, &signature_shares)?; + let signature = aggregate_signature_shares_and_verify( + params, + &verification_key, + &attributes, + &signature_shares, + )?; // Generate cryptographic material to verify them let theta = prove_bandwidth_credential( From 4899773e61d0480dd4a25184054ea1e6e074bb8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Tue, 7 May 2024 14:59:52 +0100 Subject: [PATCH 2/3] fixed unblind call in tests --- gateway/gateway-requests/src/models.rs | 10 ++++------ nym-api/src/coconut/tests/mod.rs | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/gateway/gateway-requests/src/models.rs b/gateway/gateway-requests/src/models.rs index a250612508..339715bbf7 100644 --- a/gateway/gateway-requests/src/models.rs +++ b/gateway/gateway-requests/src/models.rs @@ -316,12 +316,10 @@ mod tests { &pub_attrs, ) .unwrap(); - let sig = blind_sig - .unblind( - keypair.verification_key(), - &sig_req.pedersen_commitments_openings, - ) - .unwrap(); + let sig = blind_sig.unblind( + keypair.verification_key(), + &sig_req.pedersen_commitments_openings, + ); let issued = issuance.into_issued_credential(sig, 42); let spending = issued diff --git a/nym-api/src/coconut/tests/mod.rs b/nym-api/src/coconut/tests/mod.rs index c89d30ee3d..02c430d4c2 100644 --- a/nym-api/src/coconut/tests/mod.rs +++ b/nym-api/src/coconut/tests/mod.rs @@ -1752,12 +1752,10 @@ mod credential_tests { &pub_attrs, ) .unwrap(); - let sig = blind_sig - .unblind( - key_pair.verification_key(), - &sig_req.pedersen_commitments_openings, - ) - .unwrap(); + let sig = blind_sig.unblind( + key_pair.verification_key(), + &sig_req.pedersen_commitments_openings, + ); let issued = issuance.into_issued_credential(sig, epoch); let spending = issued From 5a35068c8782e83f44ca3b4f98e93f3fb7d3689b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Tue, 7 May 2024 15:52:53 +0100 Subject: [PATCH 3/3] fixing clippy issues in the workspace --- common/client-core/Cargo.toml | 4 ++-- .../mixnet/delegators/delegate_to_multiple_mixnodes.rs | 2 +- common/nymcoconut/src/scheme/aggregation.rs | 4 ++-- common/nymcoconut/src/scheme/mod.rs | 6 +++--- gateway/src/helpers.rs | 1 + 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/common/client-core/Cargo.toml b/common/client-core/Cargo.toml index 464cd9d25a..2f14a5b02a 100644 --- a/common/client-core/Cargo.toml +++ b/common/client-core/Cargo.toml @@ -3,7 +3,7 @@ name = "nym-client-core" version = "1.1.15" authors = ["Dave Hrycyszyn "] edition = "2021" -rust-version = "1.66" +rust-version = "1.70" license.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -48,7 +48,7 @@ nym-validator-client = { path = "../client-libs/validator-client", default-featu nym-task = { path = "../task" } nym-credential-storage = { path = "../credential-storage" } nym-network-defaults = { path = "../network-defaults" } -nym-client-core-config-types = { path = "./config-types", features = ["disk-persistence"]} +nym-client-core-config-types = { path = "./config-types", features = ["disk-persistence"] } nym-client-core-surb-storage = { path = "./surb-storage" } nym-client-core-gateways-storage = { path = "./gateways-storage" } diff --git a/common/commands/src/validator/mixnet/delegators/delegate_to_multiple_mixnodes.rs b/common/commands/src/validator/mixnet/delegators/delegate_to_multiple_mixnodes.rs index 068b24c5d2..787d27a56e 100644 --- a/common/commands/src/validator/mixnet/delegators/delegate_to_multiple_mixnodes.rs +++ b/common/commands/src/validator/mixnet/delegators/delegate_to_multiple_mixnodes.rs @@ -157,7 +157,7 @@ async fn fetch_delegation_data( // If a pending undelegate tx is found, remove it from delegation map Undelegate { owner, mix_id, .. } => { if owner == address.as_ref() - && existing_delegation_map.get(&mix_id.to_string()).is_some() + && existing_delegation_map.contains_key(&mix_id.to_string()) { existing_delegation_map.remove(&mix_id.to_string()); } diff --git a/common/nymcoconut/src/scheme/aggregation.rs b/common/nymcoconut/src/scheme/aggregation.rs index c6e71d7c03..c97fd4b8ad 100644 --- a/common/nymcoconut/src/scheme/aggregation.rs +++ b/common/nymcoconut/src/scheme/aggregation.rs @@ -231,7 +231,7 @@ mod tests { #[test] fn signature_aggregation_works_for_any_subset_of_signatures() { - let mut params = Parameters::new(2).unwrap(); + let params = Parameters::new(2).unwrap(); random_scalars_refs!(attributes, params, 2); let keypairs = ttp_keygen(¶ms, 3, 5).unwrap(); @@ -248,7 +248,7 @@ mod tests { let sigs = sks .iter() - .map(|sk| sign(&mut params, sk, &attributes).unwrap()) + .map(|sk| sign(¶ms, sk, &attributes).unwrap()) .collect::>(); // aggregating (any) threshold works diff --git a/common/nymcoconut/src/scheme/mod.rs b/common/nymcoconut/src/scheme/mod.rs index 026afe634b..691a8dc064 100644 --- a/common/nymcoconut/src/scheme/mod.rs +++ b/common/nymcoconut/src/scheme/mod.rs @@ -426,13 +426,13 @@ mod tests { #[test] fn verification_on_two_public_attributes() { - let mut params = Parameters::new(2).unwrap(); + let params = Parameters::new(2).unwrap(); random_scalars_refs!(attributes, params, 2); let keypair1 = keygen(¶ms); let keypair2 = keygen(¶ms); - let sig1 = sign(&mut params, keypair1.secret_key(), &attributes).unwrap(); - let sig2 = sign(&mut params, keypair2.secret_key(), &attributes).unwrap(); + let sig1 = sign(¶ms, keypair1.secret_key(), &attributes).unwrap(); + let sig2 = sign(¶ms, keypair2.secret_key(), &attributes).unwrap(); assert!(verify( ¶ms, diff --git a/gateway/src/helpers.rs b/gateway/src/helpers.rs index 24f7978e09..d63cc2e394 100644 --- a/gateway/src/helpers.rs +++ b/gateway/src/helpers.rs @@ -49,6 +49,7 @@ pub fn override_network_requester_config( let Some(opts) = opts else { return cfg }; // in the old code we had calls to `assert` thus panicking + #[allow(clippy::expect_used)] cfg.base .try_apply_traffic_modes( cfg.network_requester.disable_poisson_rate,