diff --git a/key_protocol/src/key_management/ephemeral_key_holder.rs b/key_protocol/src/key_management/ephemeral_key_holder.rs index 4aef8f9..8d4b3ac 100644 --- a/key_protocol/src/key_management/ephemeral_key_holder.rs +++ b/key_protocol/src/key_management/ephemeral_key_holder.rs @@ -3,11 +3,9 @@ use nssa_core::{ NullifierPublicKey, SharedSecretKey, encryption::{EphemeralPublicKey, EphemeralSecretKey, IncomingViewingPublicKey}, }; -use rand::{rngs::OsRng, RngCore}; +use rand::{RngCore, rngs::OsRng}; use sha2::Digest; -use crate::key_management::secret_holders::OutgoingViewingSecretKey; - #[derive(Debug)] ///Ephemeral secret key holder. Non-clonable as intended for one-time use. Produces ephemeral public keys. Can produce shared secret for sender. pub struct EphemeralKeyHolder { @@ -26,9 +24,7 @@ pub fn produce_one_sided_shared_secret_receiver( } impl EphemeralKeyHolder { - pub fn new( - receiver_nullifier_public_key: &NullifierPublicKey, - ) -> Self { + pub fn new(receiver_nullifier_public_key: &NullifierPublicKey) -> Self { let mut nonce_bytes = [0; 16]; OsRng.fill_bytes(&mut nonce_bytes); let mut hasher = sha2::Sha256::new(); diff --git a/key_protocol/src/key_management/mod.rs b/key_protocol/src/key_management/mod.rs index e939fcc..66e86e3 100644 --- a/key_protocol/src/key_management/mod.rs +++ b/key_protocol/src/key_management/mod.rs @@ -20,7 +20,6 @@ pub struct KeyChain { pub incoming_viewing_public_key: IncomingViewingPublicKey, } - impl KeyChain { pub fn new_os_random() -> Self { //Currently dropping SeedHolder at the end of initialization. diff --git a/nssa/core/src/account.rs b/nssa/core/src/account.rs index 8bce23c..fbd2e66 100644 --- a/nssa/core/src/account.rs +++ b/nssa/core/src/account.rs @@ -89,8 +89,7 @@ mod tests { nonce: 0xdeadbeef, }; let fingerprint = AccountId::new([8; 32]); - let new_acc_with_metadata = - AccountWithMetadata::new(account.clone(), true, fingerprint); + let new_acc_with_metadata = AccountWithMetadata::new(account.clone(), true, fingerprint); assert_eq!(new_acc_with_metadata.account, account); assert!(new_acc_with_metadata.is_authorized); assert_eq!(new_acc_with_metadata.account_id, fingerprint); diff --git a/nssa/core/src/address.rs b/nssa/core/src/address.rs index 7b8f4db..2627368 100644 --- a/nssa/core/src/address.rs +++ b/nssa/core/src/address.rs @@ -3,10 +3,10 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "host")] use std::{fmt::Display, str::FromStr}; -#[derive(Serialize, Deserialize, Clone, PartialEq, Eq)] +#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Hash)] #[cfg_attr( any(feature = "host", test), - derive(Debug, Copy, PartialOrd, Ord, Hash, Default) + derive(Debug, Copy, PartialOrd, Ord, Default) )] pub struct Address { value: [u8; 32], @@ -60,7 +60,6 @@ impl Display for Address { #[cfg(test)] mod tests { - use super::{Address, AddressError}; diff --git a/wallet/src/helperfunctions.rs b/wallet/src/helperfunctions.rs index ff0ccf9..d08f206 100644 --- a/wallet/src/helperfunctions.rs +++ b/wallet/src/helperfunctions.rs @@ -87,10 +87,7 @@ pub fn produce_data_for_storage(user_data: &NSSAUserData) -> Vec Vec { let mut result = vec![[0; 16]; size]; result.iter_mut().for_each(|bytes| OsRng.fill_bytes(bytes)); - result - .into_iter() - .map(Nonce::from_le_bytes) - .collect() + result.into_iter().map(Nonce::from_le_bytes).collect() } /// Human-readable representation of an account. diff --git a/wallet/src/lib.rs b/wallet/src/lib.rs index 116c19e..3308248 100644 --- a/wallet/src/lib.rs +++ b/wallet/src/lib.rs @@ -712,7 +712,7 @@ pub async fn execute_subcommand(command: Command) -> Result { let addr = wallet_core.create_new_account_private(); - let (key, account) = wallet_core + let (key, _) = wallet_core .storage .user_data .get_private_account(&addr) @@ -722,7 +722,7 @@ pub async fn execute_subcommand(command: Command) -> Result Result<(SendTxResponse, nssa_core::SharedSecretKey), ExecutionFailureKind> { - let Some((from_keys, mut from_acc)) = + let Some((from_keys, from_acc)) = self.storage.user_data.get_private_account(&from).cloned() else { return Err(ExecutionFailureKind::KeyNotFoundError); diff --git a/wallet/src/token_transfers/private.rs b/wallet/src/token_transfers/private.rs index c46ea85..afdbb52 100644 --- a/wallet/src/token_transfers/private.rs +++ b/wallet/src/token_transfers/private.rs @@ -12,7 +12,7 @@ impl WalletCore { to_ipk: nssa_core::encryption::IncomingViewingPublicKey, balance_to_move: u128, ) -> Result<(SendTxResponse, [nssa_core::SharedSecretKey; 2]), ExecutionFailureKind> { - let Some((from_keys, mut from_acc)) = + let Some((from_keys, from_acc)) = self.storage.user_data.get_private_account(&from).cloned() else { return Err(ExecutionFailureKind::KeyNotFoundError); @@ -107,13 +107,13 @@ impl WalletCore { to: Address, balance_to_move: u128, ) -> Result<(SendTxResponse, [nssa_core::SharedSecretKey; 2]), ExecutionFailureKind> { - let Some((from_keys, mut from_acc)) = + let Some((from_keys, from_acc)) = self.storage.user_data.get_private_account(&from).cloned() else { return Err(ExecutionFailureKind::KeyNotFoundError); }; - let Some((to_keys, mut to_acc)) = self.storage.user_data.get_private_account(&to).cloned() + let Some((to_keys, to_acc)) = self.storage.user_data.get_private_account(&to).cloned() else { return Err(ExecutionFailureKind::KeyNotFoundError); }; diff --git a/wallet/src/token_transfers/shielded.rs b/wallet/src/token_transfers/shielded.rs index a81af1e..5de293c 100644 --- a/wallet/src/token_transfers/shielded.rs +++ b/wallet/src/token_transfers/shielded.rs @@ -1,7 +1,5 @@ use common::{ExecutionFailureKind, sequencer_client::json::SendTxResponse}; -use key_protocol::key_management::ephemeral_key_holder::{ - EphemeralKeyHolder, produce_one_sided_shared_secret_receiver, -}; +use key_protocol::key_management::ephemeral_key_holder::EphemeralKeyHolder; use nssa::Address; use crate::{WalletCore, helperfunctions::produce_random_nonces}; @@ -17,7 +15,7 @@ impl WalletCore { return Err(ExecutionFailureKind::KeyNotFoundError); }; - let Some((to_keys, mut to_acc)) = self.storage.user_data.get_private_account(&to).cloned() + let Some((to_keys, to_acc)) = self.storage.user_data.get_private_account(&to).cloned() else { return Err(ExecutionFailureKind::KeyNotFoundError); };