mirror of
https://github.com/trezor/trezor-firmware.git
synced 2026-02-20 00:33:30 +01:00
fix deserialize
This commit is contained in:
@@ -3,3 +3,4 @@
|
||||
#include "elligator2.h"
|
||||
#include "hmac.h"
|
||||
#include "sha2.h"
|
||||
#include "bip32.h"
|
||||
|
||||
@@ -71,8 +71,8 @@ def main():
|
||||
print(f"Serialized ({len(request_data)} bytes): {request_data.hex()}")
|
||||
|
||||
# Load the app and get its hash
|
||||
# app_path = Path(__file__).parent.parent / "target" / "debug" / "ethereum_rust"
|
||||
app_path = Path(__file__).parent.parent / "target" / "release" / "ethereum_rust"
|
||||
app_path = Path(__file__).parent.parent / "target" / "debug" / "ethereum_rust"
|
||||
# app_path = Path(__file__).parent.parent / "target" / "release" / "ethereum_rust"
|
||||
#app_path = Path(__file__).parent.parent / "target" / "thumbv7em-none-eabihf" / "debug" / "ethereum_rust.min"
|
||||
# app_path = Path(__file__).parent.parent / "target" / "thumbv7em-none-eabihf" / "release" / "ethereum_rust.min"
|
||||
print(f"\nLoading app from: {app_path}")
|
||||
|
||||
@@ -212,12 +212,14 @@ pub fn system_exit_fatal(message: &str, file: &str, line: i32) -> ! {
|
||||
core::intrinsics::abort();
|
||||
}
|
||||
|
||||
unsafe extern "C" {
|
||||
pub fn hdnode_deserialize_public(
|
||||
str_: *const core::ffi::c_char,
|
||||
version: u32,
|
||||
curve: *const core::ffi::c_char,
|
||||
node: *mut HDNode,
|
||||
fingerprint: *mut u32,
|
||||
) -> core::ffi::c_int;
|
||||
pub fn hdnode_deserialize_public(
|
||||
str_: *const core::ffi::c_char,
|
||||
version: u32,
|
||||
curve: *const core::ffi::c_char,
|
||||
node: *mut HDNode,
|
||||
fingerprint: *mut u32,
|
||||
) -> core::ffi::c_int {
|
||||
unsafe {
|
||||
(get_crypto_or_die().hdnode_deserialize_public)(str_, version, curve, node, fingerprint)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,24 +121,12 @@ pub struct trezor_api_v1_t {
|
||||
/// Trezor crypto v1 function pointers
|
||||
#[repr(C)]
|
||||
pub struct trezor_crypto_v1_t {
|
||||
pub hdnode_from_xpub: unsafe extern "C" fn(
|
||||
depth: u32,
|
||||
child_num: u32,
|
||||
chain_code: *const u8,
|
||||
public_key: *const u8,
|
||||
curve: *const core::ffi::c_char,
|
||||
out: *mut HDNode,
|
||||
) -> core::ffi::c_int,
|
||||
pub hdnode_sign: unsafe extern "C" fn(
|
||||
pub hdnode_deserialize_public: unsafe extern "C" fn(
|
||||
str_: *const cty::c_char,
|
||||
version: u32,
|
||||
curve: *const cty::c_char,
|
||||
node: *mut HDNode,
|
||||
msg: *const u8,
|
||||
msg_len: u32,
|
||||
hasher_sign: HasherType,
|
||||
sig: *mut u8,
|
||||
pby: *mut u8,
|
||||
is_canonical: ::core::option::Option<
|
||||
unsafe extern "C" fn(by: u8, sig: *mut u8) -> core::ffi::c_int,
|
||||
>,
|
||||
fingerprint: *mut u32,
|
||||
) -> core::ffi::c_int,
|
||||
}
|
||||
|
||||
|
||||
@@ -103,15 +103,13 @@ pub fn hdnode_deserialize_public(serialized: &str, version: u32) -> Result<(HDNo
|
||||
curve: &curve_info,
|
||||
};
|
||||
let mut fingerprint: u32 = 0;
|
||||
let result = unsafe {
|
||||
low_level_api::hdnode_deserialize_public(
|
||||
serialized.as_ptr() as *const core::ffi::c_char,
|
||||
version,
|
||||
b"secp256k1\0".as_ptr() as *const core::ffi::c_char,
|
||||
&mut node,
|
||||
&mut fingerprint,
|
||||
)
|
||||
};
|
||||
let result = low_level_api::hdnode_deserialize_public(
|
||||
serialized.as_ptr() as *const core::ffi::c_char,
|
||||
version,
|
||||
b"secp256k1\0".as_ptr() as *const core::ffi::c_char,
|
||||
&mut node,
|
||||
&mut fingerprint,
|
||||
);
|
||||
if result == 0 {
|
||||
Ok((node, fingerprint))
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user