Skip to content

Commit

Permalink
refactor PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeantonio21 committed Nov 28, 2022
1 parent 806b048 commit f7ec9bb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion applications/tari_console_wallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ fn get_password(config: &ApplicationConfig, cli: &Cli) -> Option<SafePassword> {

fn get_recovery_seed(boot_mode: WalletBoot, cli: &Cli) -> Result<Option<CipherSeed>, ExitError> {
if matches!(boot_mode, WalletBoot::Recovery) {
let seed = if let Some(seed_words) = cli.seed_words.clone() {
let seed = if let Some(ref seed_words) = cli.seed_words {
get_seed_from_seed_words(seed_words)?
} else {
prompt_private_key_from_seed_words()?
Expand Down
4 changes: 2 additions & 2 deletions applications/tari_console_wallet/src/recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ pub fn prompt_private_key_from_seed_words() -> Result<CipherSeed, ExitError> {
}

/// Return seed matching the seed words.
pub fn get_seed_from_seed_words(seed_words: SeedWords) -> Result<CipherSeed, ExitError> {
pub fn get_seed_from_seed_words(seed_words: &SeedWords) -> Result<CipherSeed, ExitError> {
debug!(target: LOG_TARGET, "Return seed derived from the provided seed words");
match CipherSeed::from_mnemonic(&seed_words, None) {
match CipherSeed::from_mnemonic(seed_words, None) {
Ok(seed) => Ok(seed),
Err(e) => {
let err_msg = format!("MnemonicError parsing seed words: {}", e);
Expand Down
7 changes: 3 additions & 4 deletions comms/core/src/noise/crypto_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ use tari_crypto::{
keys::{PublicKey, SecretKey},
tari_utilities::ByteArray,
};
use tari_utilities::safe_array::SafeArray;

use super::CommsNoiseKey;
use super::{CommsNoiseKey, NOISE_KEY_LEN};
use crate::types::{CommsCoreHashDomain, CommsDHKE, CommsPublicKey, CommsSecretKey};

macro_rules! copy_slice {
Expand Down Expand Up @@ -69,7 +68,7 @@ impl CryptoResolver for TariCryptoResolver {

fn noise_kdf(shared_key: &CommsDHKE) -> CommsNoiseKey {
let hasher = DomainSeparatedHasher::<Blake256, CommsCoreHashDomain>::new_with_label("noise.dh");
let mut comms_noise_kdf = CommsNoiseKey::from(SafeArray::default());
let mut comms_noise_kdf = CommsNoiseKey::from([0u8; NOISE_KEY_LEN]);
comms_noise_kdf
.reveal_mut()
.copy_from_slice(hasher.chain(shared_key.as_bytes()).finalize().as_ref());
Expand Down Expand Up @@ -131,7 +130,7 @@ mod test {
use snow::Keypair;

use super::*;
use crate::noise::{config::NOISE_IX_PARAMETER, NOISE_KEY_LEN};
use crate::noise::config::NOISE_IX_PARAMETER;

fn build_keypair() -> Keypair {
snow::Builder::with_resolver(
Expand Down
4 changes: 2 additions & 2 deletions comms/core/src/noise/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ pub use error::NoiseError;

mod socket;
pub use socket::NoiseSocket;
use tari_utilities::{hidden_type, safe_array::SafeArray, Hidden};
use tari_utilities::{hidden_type, Hidden};
use zeroize::Zeroize;

pub(crate) const NOISE_KEY_LEN: usize = 32;

hidden_type!(CommsNoiseKey, SafeArray<u8, NOISE_KEY_LEN>);
hidden_type!(CommsNoiseKey, [u8; NOISE_KEY_LEN]);

0 comments on commit f7ec9bb

Please sign in to comment.