Skip to content

Commit

Permalink
Updated the parser in get_address_and_pubkey of the Rust library.
Browse files Browse the repository at this point in the history
  • Loading branch information
murisi committed Jun 13, 2024
1 parent 3052d7c commit 4a25358
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion deps/ledger-secure-sdk
Submodule ledger-secure-sdk updated 126 files
2 changes: 1 addition & 1 deletion deps/nanos-secure-sdk
Submodule nanos-secure-sdk updated 2283 files
2 changes: 1 addition & 1 deletion deps/nanosplus-secure-sdk
2 changes: 1 addition & 1 deletion deps/nanox-secure-sdk
14 changes: 7 additions & 7 deletions rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,19 @@ where
}
}

let mut public_key = [0; ED25519_PUBKEY_LEN + 1];
public_key.copy_from_slice(&response_data[..ED25519_PUBKEY_LEN + 1]);

let mut address_bytes = [0; ADDRESS_LEN];
address_bytes.copy_from_slice(&response_data[ED25519_PUBKEY_LEN + 1..]);
let (raw_public_key, rest) = response_data.split_at(ED25519_PUBKEY_LEN + 1);
let (public_key_len, rest) = rest.split_first().expect("response too short");
let (_public_key, rest) = rest.split_at((*public_key_len).into());
let (address_len, rest) = rest.split_first().expect("response too short");
let (address_bytes, _rest) = rest.split_at((*address_len).into());

let address_str = str::from_utf8(&address_bytes)
.map_err(|_| LedgerAppError::Utf8)?
.to_owned();

Ok(ResponseAddress {
public_key,
address_bytes,
public_key: raw_public_key.try_into().unwrap(),
address_bytes: address_bytes.try_into().unwrap(),
address_str,
})
}
Expand Down

0 comments on commit 4a25358

Please sign in to comment.