diff --git a/applications/minotari_ledger_wallet/wallet/src/handlers/get_public_alpha.rs b/applications/minotari_ledger_wallet/wallet/src/handlers/get_public_alpha.rs index 983c617730a..3904303734a 100644 --- a/applications/minotari_ledger_wallet/wallet/src/handlers/get_public_alpha.rs +++ b/applications/minotari_ledger_wallet/wallet/src/handlers/get_public_alpha.rs @@ -1,17 +1,10 @@ // Copyright 2024 The Tari Project // SPDX-License-Identifier: BSD-3-Clause -use ledger_device_sdk::{io::Comm, ui::gadgets::MessageScroller}; +use ledger_device_sdk::io::Comm; use tari_crypto::{keys::PublicKey, ristretto::RistrettoPublicKey, tari_utilities::ByteArray}; -use crate::{ - alloc::string::ToString, - utils::derive_from_bip32_key, - AppSW, - KeyType, - RESPONSE_VERSION, - STATIC_ALPHA_INDEX, -}; +use crate::{utils::derive_from_bip32_key, AppSW, KeyType, RESPONSE_VERSION, STATIC_ALPHA_INDEX}; pub fn handler_get_public_alpha(comm: &mut Comm) -> Result<(), AppSW> { let data = comm.get_data().map_err(|_| AppSW::WrongApduLength)?; @@ -25,8 +18,6 @@ pub fn handler_get_public_alpha(comm: &mut Comm) -> Result<(), AppSW> { Err(e) => return Err(e), }; - MessageScroller::new(&pk.to_string()).event_loop(); - comm.append(&[RESPONSE_VERSION]); // version comm.append(pk.as_bytes()); comm.reply_ok(); diff --git a/applications/minotari_ledger_wallet/wallet/src/handlers/get_script_offset.rs b/applications/minotari_ledger_wallet/wallet/src/handlers/get_script_offset.rs index 12749630e8f..ec2b8e768d1 100644 --- a/applications/minotari_ledger_wallet/wallet/src/handlers/get_script_offset.rs +++ b/applications/minotari_ledger_wallet/wallet/src/handlers/get_script_offset.rs @@ -1,17 +1,11 @@ // Copyright 2024 The Tari Project // SPDX-License-Identifier: BSD-3-Clause -use ledger_device_sdk::{ - io::Comm, - ui::gadgets::{MessageScroller, SingleMessage}, -}; -use tari_crypto::{ - ristretto::RistrettoSecretKey, - tari_utilities::{hex::Hex, ByteArray}, -}; +use ledger_device_sdk::io::Comm; +use tari_crypto::{ristretto::RistrettoSecretKey, tari_utilities::ByteArray}; use crate::{ - utils::{alpha_hasher, derive_from_bip32_key, get_key_from_canonical_bytes, u64_to_string}, + utils::{alpha_hasher, derive_from_bip32_key, get_key_from_canonical_bytes}, AppSW, KeyType, RESPONSE_VERSION, @@ -89,11 +83,13 @@ pub fn handler_get_script_offset( // The sum of managed private keys let k: RistrettoSecretKey = get_key_from_canonical_bytes(&data[0..32])?; offset_ctx.total_script_private_key = &offset_ctx.total_script_private_key + k; + return Ok(()); } let payload_offset = 2; let end_offset_indexes = payload_offset + offset_ctx.total_offset_indexes; + if (payload_offset..end_offset_indexes).contains(&(chunk as u64)) { let mut index_bytes = [0u8; 8]; index_bytes.clone_from_slice(&data[0..8]); @@ -104,11 +100,12 @@ pub fn handler_get_script_offset( } let end_commitment_keys = end_offset_indexes + offset_ctx.total_commitment_keys; + if (end_offset_indexes..end_commitment_keys).contains(&(chunk as u64)) { let alpha = derive_from_bip32_key(offset_ctx.account, STATIC_ALPHA_INDEX, KeyType::Alpha)?; - let blinding_factor = get_key_from_canonical_bytes(&data[0..32])?; - let k = alpha_hasher(alpha, blinding_factor)?; + let blinding_factor: RistrettoSecretKey = get_key_from_canonical_bytes(&data[0..32])?; + let k = alpha_hasher(alpha, blinding_factor)?; offset_ctx.total_script_private_key = &offset_ctx.total_script_private_key + &k; } diff --git a/applications/minotari_ledger_wallet/wallet/src/handlers/get_script_signature.rs b/applications/minotari_ledger_wallet/wallet/src/handlers/get_script_signature.rs index 611e8833f4e..af0abd371a6 100644 --- a/applications/minotari_ledger_wallet/wallet/src/handlers/get_script_signature.rs +++ b/applications/minotari_ledger_wallet/wallet/src/handlers/get_script_signature.rs @@ -1,26 +1,18 @@ // Copyright 2024 The Tari Project // SPDX-License-Identifier: BSD-3-Clause -use alloc::{format, str::from_utf8}; +use alloc::format; -use ledger_device_sdk::{ - io::Comm, - ui::gadgets::{MessageScroller, SingleMessage}, -}; -use tari_crypto::{ - keys::PublicKey, - ristretto::{ - pedersen::extended_commitment_factory::ExtendedPedersenCommitmentFactory, - RistrettoComAndPubSig, - RistrettoPublicKey, - RistrettoSecretKey, - }, - tari_utilities::{hex::Hex, ByteArray}, +use ledger_device_sdk::{io::Comm, ui::gadgets::SingleMessage}; +use tari_crypto::ristretto::{ + pedersen::extended_commitment_factory::ExtendedPedersenCommitmentFactory, + RistrettoComAndPubSig, + RistrettoSecretKey, }; use crate::{ alloc::string::ToString, - utils::{alpha_hasher, derive_from_bip32_key, get_key_from_canonical_bytes, special_hash, u64_to_string}, + utils::{alpha_hasher, derive_from_bip32_key, get_key_from_canonical_bytes}, AppSW, KeyType, RESPONSE_VERSION, @@ -82,20 +74,11 @@ pub fn handler_get_script_signature( let mut account_bytes = [0u8; 8]; account_bytes.clone_from_slice(&signer_ctx.payload[0..8]); signer_ctx.account = u64::from_le_bytes(account_bytes); - MessageScroller::new(&u64_to_string(signer_ctx.account)).event_loop(); let alpha = derive_from_bip32_key(signer_ctx.account, STATIC_ALPHA_INDEX, KeyType::Alpha)?; let blinding_factor: RistrettoSecretKey = get_key_from_canonical_bytes(&signer_ctx.payload[8..40])?; - let alpha_pk = RistrettoPublicKey::from_secret_key(&alpha); let script_private_key = alpha_hasher(alpha, blinding_factor)?; - let pk = RistrettoPublicKey::from_secret_key(&script_private_key); - - MessageScroller::new(&alpha_pk.to_string()).event_loop(); - MessageScroller::new(&pk.to_string()).event_loop(); - MessageScroller::new(&(&pk + alpha_pk).to_string()).event_loop(); - special_hash(); - let value: RistrettoSecretKey = get_key_from_canonical_bytes(&signer_ctx.payload[40..72])?; let spend_private_key: RistrettoSecretKey = get_key_from_canonical_bytes(&signer_ctx.payload[72..104])?; let r_a: RistrettoSecretKey = get_key_from_canonical_bytes(&signer_ctx.payload[104..136])?; diff --git a/applications/minotari_ledger_wallet/wallet/src/utils.rs b/applications/minotari_ledger_wallet/wallet/src/utils.rs index 39b0d7e9da3..dda4c610867 100644 --- a/applications/minotari_ledger_wallet/wallet/src/utils.rs +++ b/applications/minotari_ledger_wallet/wallet/src/utils.rs @@ -8,14 +8,14 @@ use digest::consts::U64; use ledger_device_sdk::{ ecc::{bip32_derive, make_bip32_path, CurvesId, CxError}, io::SyscallError, - ui::gadgets::{MessageScroller, SingleMessage}, + ui::gadgets::SingleMessage, }; use tari_crypto::{ hash_domain, hashing::DomainSeparatedHasher, - keys::{PublicKey, SecretKey}, + keys::SecretKey, ristretto::{pedersen::PedersenCommitment, RistrettoPublicKey, RistrettoSecretKey}, - tari_utilities::{hex::Hex, ByteArray}, + tari_utilities::ByteArray, }; use zeroize::Zeroizing; @@ -248,11 +248,6 @@ pub fn derive_from_bip32_key( let index = u64_to_string(u64_index); let key_type = u64_to_string(u64_key_type.as_byte() as u64); - // MessageScroller::new(&"derive").event_loop(); - // MessageScroller::new(&account).event_loop(); - // MessageScroller::new(&index).event_loop(); - // MessageScroller::new(&key_type).event_loop(); - let mut bip32_path = "m/44'/".to_string(); bip32_path.push_str(&BIP32_COIN_TYPE.to_string()); bip32_path.push_str(&"'/"); @@ -281,13 +276,6 @@ pub fn finalize_metadata_signature_challenge( commitment: &PedersenCommitment, message: &[u8; 32], ) -> [u8; 64] { - // let network_str = u64_to_string(network); - // MessageScroller::new(&network_str).event_loop(); - // MessageScroller::new(&sender_offset_public_key.to_string()).event_loop(); - // MessageScroller::new(&ephemeral_commitment.as_public_key().to_string()).event_loop(); - // MessageScroller::new(&ephemeral_pubkey.to_string()).event_loop(); - // MessageScroller::new(&commitment.as_public_key().to_string()).event_loop(); - let challenge = DomainSeparatedConsensusHasher::>::new("metadata_signature", network) .chain(ephemeral_pubkey) @@ -299,13 +287,3 @@ pub fn finalize_metadata_signature_challenge( challenge.into() } - -pub fn special_hash() { - let hasher = DomainSeparatedHasher::, KeyManagerTransactionsHashDomain>::new_with_label("script key"); - let hasher = hasher.chain("test input".as_bytes()).finalize(); - let private_key = RistrettoSecretKey::from_uniform_bytes(hasher.as_ref()).unwrap(); - MessageScroller::new(&private_key.to_hex()).event_loop(); - let public_key = RistrettoPublicKey::from_secret_key(&private_key); - - MessageScroller::new(&public_key.to_string()).event_loop(); -}