Skip to content

Commit

Permalink
working
Browse files Browse the repository at this point in the history
  • Loading branch information
SWvheerden committed Feb 25, 2025
1 parent 73682e6 commit ea80f29
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,20 @@ pub fn handler_get_script_schnorr_signature(comm: &mut Comm) -> Result<(), AppSW
}
return Err(AppSW::WrongApduLength);
}

let mut account_bytes = [0u8; 8];
account_bytes.clone_from_slice(&data[0..8]);
let account = u64::from_le_bytes(account_bytes);

let mut private_key_index_bytes = [0u8; 8];
private_key_index_bytes.clone_from_slice(&data[8..16]);
let private_key_index = u64::from_le_bytes(private_key_index_bytes);

let mut private_key_type_bytes = [0u8; 8];

private_key_type_bytes.clone_from_slice(&data[16..24]);
let key_type = u64::from_le_bytes(private_key_type_bytes);
let private_key_type = KeyType::from_branch_key(key_type)?;

let private_key = derive_from_bip32_key(account, private_key_index, private_key_type)?;

let mut nonce_bytes = [0u8; 32];
nonce_bytes.clone_from_slice(&data[24..56]);

Expand All @@ -149,7 +147,6 @@ pub fn handler_get_script_schnorr_signature(comm: &mut Comm) -> Result<(), AppSW
return Err(AppSW::SchnorrSignatureFail);
},
};

comm.append(&[RESPONSE_VERSION]); // version
comm.append(&signature.get_public_nonce().to_vec());
comm.append(&signature.get_signature().to_vec());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use alloc::{format, string::String};
use core::marker::PhantomData;

use blake2::{Blake2b, Blake2bVar};
use digest::{Digest, FixedOutput, FixedOutputReset, Output, OutputSizeUser, Update};

use crate::hashing::DomainSeparatedHash;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use curve25519_dalek::{
constants::RISTRETTO_BASEPOINT_TABLE,
ristretto::{CompressedRistretto, RistrettoPoint},
scalar::Scalar,
traits::MultiscalarMul,
};
use digest::{consts::U64, Digest};
use rand_core::{CryptoRng, RngCore};
Expand Down
7 changes: 4 additions & 3 deletions applications/minotari_ledger_wallet/wallet/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,17 @@ fn cx_error_to_string(e: CxError) -> String {
// ever used in a subsequent key derivation function.
fn get_raw_bip32_key(path: &[u32]) -> Result<Zeroizing<[u8; 64]>, String> {
let mut key_buffer = Zeroizing::new([0u8; 64]);
match bip32_derive(CurvesId::Secp256k1, path, key_buffer.as_mut(), Some(&mut [])) {
match bip32_derive(CurvesId::Secp256k1, path, key_buffer.as_mut(), None) {
Ok(_) => {
if key_buffer.deref() == &[0u8; 64] {
return Err(cx_error_to_string(CxError::InternalError));
} else {
Ok(key_buffer)
}
},
Err(e) => return Err(cx_error_to_string(e)),
Err(e) => {
return Err(cx_error_to_string(e))
},
}
}

Expand All @@ -177,7 +179,6 @@ fn get_raw_key_hash(path: &[u32]) -> Result<Zeroizing<[u8; 64]>, String> {
DomainSeparatedHasher::<Blake2b<U64>, LedgerHashDomain>::new_with_label("raw_key")
.chain(&raw_key_64.as_ref())
.finalize_into(raw_key_hashed.as_mut().into());

Ok(raw_key_hashed)
}

Expand Down

0 comments on commit ea80f29

Please sign in to comment.