diff --git a/common/cosmwasm-smart-contracts/coconut-bandwidth-contract/src/spend_credential.rs b/common/cosmwasm-smart-contracts/coconut-bandwidth-contract/src/spend_credential.rs index 835d6175de..3ab4e72150 100644 --- a/common/cosmwasm-smart-contracts/coconut-bandwidth-contract/src/spend_credential.rs +++ b/common/cosmwasm-smart-contracts/coconut-bandwidth-contract/src/spend_credential.rs @@ -142,7 +142,7 @@ pub fn funds_from_cosmos_msgs(msgs: Vec) -> Option { contract_addr: _, msg, funds: _, - })) = msgs.get(0) + })) = msgs.first() { if let Ok(ExecuteMsg::ReleaseFunds { funds }) = from_binary::(msg) { return Some(funds); diff --git a/common/cosmwasm-smart-contracts/coconut-dkg/src/verification_key.rs b/common/cosmwasm-smart-contracts/coconut-dkg/src/verification_key.rs index 7a3d02f2e8..188215b3b0 100644 --- a/common/cosmwasm-smart-contracts/coconut-dkg/src/verification_key.rs +++ b/common/cosmwasm-smart-contracts/coconut-dkg/src/verification_key.rs @@ -62,7 +62,7 @@ pub fn owner_from_cosmos_msgs(msgs: &[CosmosMsg]) -> Option { contract_addr: _, msg, funds: _, - })) = msgs.get(0) + })) = msgs.first() { if let Ok(ExecuteMsg::VerifyVerificationKeyShare { owner, .. }) = from_binary::(msg) diff --git a/common/cosmwasm-smart-contracts/vesting-contract/src/account.rs b/common/cosmwasm-smart-contracts/vesting-contract/src/account.rs index 0d1e5b754e..5768cde2f5 100644 --- a/common/cosmwasm-smart-contracts/vesting-contract/src/account.rs +++ b/common/cosmwasm-smart-contracts/vesting-contract/src/account.rs @@ -49,7 +49,7 @@ impl Account { pub fn period_duration(&self) -> Result { self.periods - .get(0) + .first() .ok_or(VestingContractError::UnpopulatedVestingPeriods { owner: self.owner_address.clone(), }) diff --git a/common/dkg/src/dealing.rs b/common/dkg/src/dealing.rs index ff31c5736e..1e0363635f 100644 --- a/common/dkg/src/dealing.rs +++ b/common/dkg/src/dealing.rs @@ -115,11 +115,7 @@ impl Dealing { .map(|&node_index| polynomial.evaluate_at(&Scalar::from(node_index)).into()) .collect::>(); - let remote_share_key_pairs = shares - .iter() - .zip(receivers.values()) - .map(|(share, key)| (share, key)) - .collect::>(); + let remote_share_key_pairs = shares.iter().zip(receivers.values()).collect::>(); let ordered_public_keys = receivers.values().copied().collect::>(); let (ciphertexts, hazmat) = encrypt_shares(&remote_share_key_pairs, params, &mut rng); diff --git a/common/nymcoconut/src/scheme/aggregation.rs b/common/nymcoconut/src/scheme/aggregation.rs index 499dca4e3f..e41beb8d36 100644 --- a/common/nymcoconut/src/scheme/aggregation.rs +++ b/common/nymcoconut/src/scheme/aggregation.rs @@ -50,7 +50,7 @@ where impl Aggregatable for PartialSignature { fn aggregate(sigs: &[PartialSignature], indices: Option<&[u64]>) -> Result { let h = sigs - .get(0) + .first() .ok_or_else(|| CoconutError::Aggregation("Empty set of signatures".to_string()))? .sig1(); diff --git a/common/wireguard-types/src/registration.rs b/common/wireguard-types/src/registration.rs index 0fa9536161..ceabc625c3 100644 --- a/common/wireguard-types/src/registration.rs +++ b/common/wireguard-types/src/registration.rs @@ -93,8 +93,7 @@ impl GatewayClient { ) -> Self { // convert from 1.0 x25519-dalek private key into 2.0 x25519-dalek #[allow(clippy::expect_used)] - let static_secret = boringtun::x25519::StaticSecret::try_from(local_secret.to_bytes()) - .expect("conversion between x25519 private keys is infallible"); + let static_secret = boringtun::x25519::StaticSecret::from(local_secret.to_bytes()); let local_public: boringtun::x25519::PublicKey = (&static_secret).into(); let remote_public = boringtun::x25519::PublicKey::from(remote_public.to_bytes()); @@ -123,8 +122,7 @@ impl GatewayClient { pub fn verify(&self, gateway_key: &PrivateKey, nonce: u64) -> Result<(), Error> { // convert from 1.0 x25519-dalek private key into 2.0 x25519-dalek #[allow(clippy::expect_used)] - let static_secret = boringtun::x25519::StaticSecret::try_from(gateway_key.to_bytes()) - .expect("conversion between x25519 private keys is infallible"); + let static_secret = boringtun::x25519::StaticSecret::from(gateway_key.to_bytes()); let dh = static_secret.diffie_hellman(&self.pub_key); diff --git a/common/wireguard/src/setup.rs b/common/wireguard/src/setup.rs index 04c11a3b55..a4ee4e582d 100644 --- a/common/wireguard/src/setup.rs +++ b/common/wireguard/src/setup.rs @@ -31,7 +31,7 @@ fn decode_base64_key(base64_key: &str) -> [u8; 32] { pub fn server_static_private_key() -> x25519::StaticSecret { // TODO: this is a temporary solution for development let static_private_bytes: [u8; 32] = decode_base64_key(PRIVATE_KEY); - let static_private = x25519::StaticSecret::try_from(static_private_bytes).unwrap(); + let static_private = x25519::StaticSecret::from(static_private_bytes); let static_public = x25519::PublicKey::from(&static_private); info!( "wg public key: {}", @@ -47,7 +47,7 @@ pub fn peer_static_public_key() -> x25519::PublicKey { let peer = std::env::var("NYM_PEER_PUBLIC_KEY").expect("NYM_PEER_PUBLIC_KEY must be set"); let peer_static_public_bytes: [u8; 32] = decode_base64_key(&peer); - let peer_static_public = x25519::PublicKey::try_from(peer_static_public_bytes).unwrap(); + let peer_static_public = x25519::PublicKey::from(peer_static_public_bytes); info!( "Adding wg peer public key: {}", general_purpose::STANDARD.encode(peer_static_public) diff --git a/ephemera/src/config/mod.rs b/ephemera/src/config/mod.rs index bf30850928..703aed14a7 100644 --- a/ephemera/src/config/mod.rs +++ b/ephemera/src/config/mod.rs @@ -136,7 +136,7 @@ pub enum Error { NotFound(String), #[error("Configuration file does not exist")] /// This is returned if IoError happens during configuration file read/write. - IoError(#[from] std::io::Error), + Io(#[from] std::io::Error), /// This is returned if configuration file is invalid. #[error("Configuration file is invalid: '{0}'")] InvalidFormat(String), diff --git a/mixnode/src/config/mod.rs b/mixnode/src/config/mod.rs index 97ad26d699..1046641feb 100644 --- a/mixnode/src/config/mod.rs +++ b/mixnode/src/config/mod.rs @@ -164,6 +164,7 @@ impl Config { save_formatted_config_to_file(self, config_save_location) } + #[allow(unused)] pub fn try_save(&self) -> io::Result<()> { if let Some(save_location) = &self.save_path { save_formatted_config_to_file(self, save_location) diff --git a/nym-api/src/coconut/deposit.rs b/nym-api/src/coconut/deposit.rs index 3d6b8fb2de..d92e5f1d5f 100644 --- a/nym-api/src/coconut/deposit.rs +++ b/nym-api/src/coconut/deposit.rs @@ -46,7 +46,7 @@ pub async fn extract_encryption_key( .ok_or(CoconutError::DepositValueNotFound)? .value .as_ref(); - let deposit_value_plain = public_attributes_plain.get(0).cloned().unwrap_or_default(); + let deposit_value_plain = public_attributes_plain.first().cloned().unwrap_or_default(); if deposit_value != deposit_value_plain { return Err(CoconutError::DifferentPublicAttributes( deposit_value.to_string(), diff --git a/nym-node/src/http/router/api/v1/gateway/client_interfaces/wireguard/mod.rs b/nym-node/src/http/router/api/v1/gateway/client_interfaces/wireguard/mod.rs index d2dbcb579c..4008c312b6 100644 --- a/nym-node/src/http/router/api/v1/gateway/client_interfaces/wireguard/mod.rs +++ b/nym-node/src/http/router/api/v1/gateway/client_interfaces/wireguard/mod.rs @@ -144,13 +144,10 @@ mod test { .unwrap(); let client_key_pair = encryption::KeyPair::new(&mut rng); - let gateway_static_public = - PublicKey::try_from(gateway_key_pair.public_key().to_bytes()).unwrap(); + let gateway_static_public = PublicKey::from(gateway_key_pair.public_key().to_bytes()); - let client_static_private = - StaticSecret::try_from(client_key_pair.private_key().to_bytes()).unwrap(); - let client_static_public = - PublicKey::try_from(client_key_pair.public_key().to_bytes()).unwrap(); + let client_static_private = StaticSecret::from(client_key_pair.private_key().to_bytes()); + let client_static_public = PublicKey::from(client_key_pair.public_key().to_bytes()); let client_dh = client_static_private.diffie_hellman(&gateway_static_public); diff --git a/nym-outfox/src/format.rs b/nym-outfox/src/format.rs index a613c55894..1d0a3681c5 100644 --- a/nym-outfox/src/format.rs +++ b/nym-outfox/src/format.rs @@ -302,7 +302,7 @@ impl MixStageParameters { &nonce.into(), &[], &mut buffer[self.header_range()], - tag.as_slice().try_into().unwrap(), + tag.as_slice().into(), ) .map_err(|e| OutfoxError::ChaCha20Poly1305Error(e.to_string()))?;