Skip to content

Commit 0d40913

Browse files
committed
rust: use .into not .try_into for hash->array conversion
Since digest-0.13.0, one can convert directly to the `[u8;32]` array. This does not change the compilation output at all (identical binaries).
1 parent 81a59e5 commit 0d40913

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/rust/bitbox02-rust/src/hww/api/bitcoin/signtx.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -941,11 +941,11 @@ async fn _process(request: &pb::BtcSignInitRequest) -> Result<Response, Error> {
941941
let sighash = bip341::sighash(&bip341::Args {
942942
version: request.version,
943943
locktime: request.locktime,
944-
hash_prevouts: hash_prevouts.as_slice().try_into().unwrap(),
945-
hash_amounts: hash_amounts.as_slice().try_into().unwrap(),
946-
hash_scriptpubkeys: hash_scriptpubkeys.as_slice().try_into().unwrap(),
947-
hash_sequences: hash_sequence.as_slice().try_into().unwrap(),
948-
hash_outputs: hash_outputs.as_slice().try_into().unwrap(),
944+
hash_prevouts: hash_prevouts.into(),
945+
hash_amounts: hash_amounts.into(),
946+
hash_scriptpubkeys: hash_scriptpubkeys.into(),
947+
hash_sequences: hash_sequence.into(),
948+
hash_outputs: hash_outputs.into(),
949949
input_index,
950950
});
951951
next_response.next.has_signature = true;

src/rust/bitbox02-rust/src/hww/api/ethereum/signmsg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub async fn process(request: &pb::EthSignMessageRequest) -> Result<Response, Er
5858
msg.extend(format!("{}", request.msg.len()).as_bytes());
5959
msg.extend(&request.msg);
6060

61-
let sighash: [u8; 32] = sha3::Keccak256::digest(&msg).as_slice().try_into().unwrap();
61+
let sighash: [u8; 32] = sha3::Keccak256::digest(&msg).into();
6262

6363
let host_nonce = match request.host_nonce_commitment {
6464
// Engage in the anti-klepto protocol if the host sends a host nonce commitment.

0 commit comments

Comments
 (0)