Skip to content

Commit 8353047

Browse files
authored
Merge pull request LedgerHQ#22 from LedgerHQ/seed_derive_update
[fix] Use SeedDerive trait
2 parents e454411 + 3c8afbc commit 8353047

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ mod utils;
55

66
use core::str::from_utf8;
77
use nanos_sdk::buttons::ButtonEvent;
8-
use nanos_sdk::ecc::Secp256k1;
8+
use nanos_sdk::ecc::{Secp256k1, SeedDerive};
99
use nanos_sdk::io;
1010
use nanos_sdk::io::SyscallError;
1111
use nanos_ui::ui;
@@ -17,7 +17,7 @@ pub const BIP32_PATH: [u32; 5] = nanos_sdk::ecc::make_bip32_path(b"m/44'/535348'
1717
/// Display public key in two separate
1818
/// message scrollers
1919
fn show_pubkey() {
20-
let pubkey = Secp256k1::from_bip32(&BIP32_PATH).public_key();
20+
let pubkey = Secp256k1::derive_from_path(&BIP32_PATH).public_key();
2121
match pubkey {
2222
Ok(pk) => {
2323
{
@@ -59,7 +59,7 @@ fn menu_example() {
5959
/// This is the UI flow for signing, composed of a scroller
6060
/// to read the incoming message, a panel that requests user
6161
/// validation, and an exit message.
62-
fn sign_ui(message: &[u8]) -> Result<Option<([u8; 72], u32)>, SyscallError> {
62+
fn sign_ui(message: &[u8]) -> Result<Option<([u8; 72], u32, u32)>, SyscallError> {
6363
ui::popup("Message review");
6464

6565
{
@@ -70,7 +70,7 @@ fn sign_ui(message: &[u8]) -> Result<Option<([u8; 72], u32)>, SyscallError> {
7070
}
7171

7272
if ui::Validator::new("Sign ?").ask() {
73-
let signature = Secp256k1::from_bip32(&BIP32_PATH)
73+
let signature = Secp256k1::derive_from_path(&BIP32_PATH)
7474
.deterministic_sign(message)
7575
.map_err(|_| SyscallError::Unspecified)?;
7676
ui::popup("Done !");
@@ -131,14 +131,14 @@ fn handle_apdu(comm: &mut io::Comm, ins: Ins) -> Result<(), Reply> {
131131

132132
match ins {
133133
Ins::GetPubkey => {
134-
let pk = Secp256k1::from_bip32(&BIP32_PATH)
134+
let pk = Secp256k1::derive_from_path(&BIP32_PATH)
135135
.public_key()
136136
.map_err(|x| Reply(0x6eu16 | (x as u16 & 0xff)))?;
137137
comm.append(pk.as_ref());
138138
}
139139
Ins::Sign => {
140140
let out = sign_ui(comm.get_data()?)?;
141-
if let Some((signature_buf, length)) = out {
141+
if let Some((signature_buf, length, _)) = out {
142142
comm.append(&signature_buf[..length as usize])
143143
}
144144
}

0 commit comments

Comments
 (0)