From ee95bc1306e94be3d1b5ab1026248a337c004f5d Mon Sep 17 00:00:00 2001 From: bunnie Date: Wed, 31 Jan 2024 04:04:16 +0800 Subject: [PATCH] specify use of sw-only hasher in bip39 the hash is tiny, hw overhead not worth it --- services/gam/src/bip39.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/gam/src/bip39.rs b/services/gam/src/bip39.rs index b8c55d008..d19b3ed88 100644 --- a/services/gam/src/bip39.rs +++ b/services/gam/src/bip39.rs @@ -31,7 +31,7 @@ pub(crate) fn bytes_to_bip39(bytes: &Vec) -> Result, Bip39Error> 16 | 20 | 24 | 28 | 32 => (), _ => return Err(Bip39Error::InvalidLength), } - let mut hasher = sha2::Sha256::new(); + let mut hasher = sha2::Sha256Sw::new(); hasher.update(bytes); let digest = hasher.finalize(); let checksum_bits = bytes.len() / 4; @@ -112,7 +112,7 @@ pub(crate) fn bip39_to_bytes(bip39: &Vec) -> Result, Bip39Error> bucket as u8 }; - let mut hasher = sha2::Sha256::new(); + let mut hasher = sha2::Sha256Sw::new(); hasher.update(&data); let digest = hasher.finalize(); let checksum_bits = data.len() / 4;