Skip to content

Commit

Permalink
chore: some cleanup (#45)
Browse files Browse the repository at this point in the history
* fix: typo on secp256k1 name

* chore: remove unused consts
  • Loading branch information
emmanuelm41 authored Nov 26, 2024
1 parent d2650a2 commit 13c6ebb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
10 changes: 5 additions & 5 deletions ledger-zcash/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use zx_bip44::BIP44Path;

use crate::config::*;

type PublicKeySecp256k1 = [u8; PK_LEN_SECP261K1];
type PublicKeySecp256k1 = [u8; PK_LEN_SECP256K1];
type PaymentAddressRaw = [u8; PK_LEN_SAPLING];

type OutgoingViewKeyRaw = [u8; OVK_SIZE];
Expand Down Expand Up @@ -222,18 +222,18 @@ where
}

let response_data = response.data();
if response_data.len() < PK_LEN_SECP261K1 {
if response_data.len() < PK_LEN_SECP256K1 {
return Err(LedgerAppError::InvalidPK);
}

log::info!("Received response {}", response_data.len());

let mut address = AddressUnshielded { public_key: [0; PK_LEN_SECP261K1], address: "".to_string() };
let mut address = AddressUnshielded { public_key: [0; PK_LEN_SECP256K1], address: "".to_string() };

address
.public_key
.copy_from_slice(&response_data[.. PK_LEN_SECP261K1]);
str::from_utf8(&response_data[PK_LEN_SECP261K1 ..])
.copy_from_slice(&response_data[.. PK_LEN_SECP256K1]);
str::from_utf8(&response_data[PK_LEN_SECP256K1 ..])
.map_err(|_e| LedgerAppError::Utf8)?
.clone_into(&mut address.address);

Expand Down
14 changes: 1 addition & 13 deletions ledger-zcash/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,10 @@ pub const HASHSEED_SIZE: usize = 32;
pub const OUTPUTDATA_SIZE: usize = RCV_SIZE + RSEED_SIZE;

/// Public Key Length for secp256k1
pub const PK_LEN_SECP261K1: usize = 33;
pub const PK_LEN_SECP256K1: usize = 33;

/// Public Key Length for Sapling
pub const PK_LEN_SAPLING: usize = 43;

/// Transparent input size: BIP44-path (20) + script (26) + value (8)
pub const T_IN_INPUT_SIZE: usize = 54;

/// Transparent output size: script (26) + value (8)
pub const T_OUT_INPUT_SIZE: usize = 34;

/// Shielded spend input size: zip32-path (4) + address (43) + value (8)
pub const S_SPEND_INPUT_SIZE: usize = 55;

/// Shielded output input size: address (43) + value (8) + memotype (1) + ovk(32)
pub const S_OUT_INPUT_SIZE: usize = 84;

/// Signature size for transparent and shielded signatures
pub const SIG_SIZE: usize = 64;

0 comments on commit 13c6ebb

Please sign in to comment.