Skip to content

Commit 824e668

Browse files
committed
Fix seed64 for spark wallets
1 parent 742ff9b commit 824e668

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

orange-sdk/src/trusted_wallet/spark.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! An implementation of `TrustedWalletInterface` using the Spark SDK.
2+
use crate::bitcoin::hashes::{Hash, sha256};
23
use crate::bitcoin::hex::FromHex;
34
use crate::bitcoin::{Network, io};
45
use crate::logging::Logger;
@@ -239,7 +240,9 @@ impl Spark {
239240

240241
let (mnemonic, passphrase) = match &config.seed {
241242
Seed::Seed64(bytes) => {
242-
let mnemonic = Mnemonic::from_entropy(bytes.as_slice()).expect("valid length");
243+
// max entropy for bip39 is 32 bytes, so we hash the 64 bytes down to 32
244+
let hash = sha256::Hash::hash(bytes);
245+
let mnemonic = Mnemonic::from_entropy(hash.as_byte_array()).expect("valid length");
243246
(mnemonic.to_string(), None)
244247
},
245248
Seed::Mnemonic { mnemonic, passphrase } => (mnemonic.to_string(), passphrase.clone()),

0 commit comments

Comments
 (0)