From 55b41a49efa8f9c3e05f5a7560e5e16444abf0fb Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 26 Dec 2023 18:07:56 -0500 Subject: [PATCH] keyfork-mnemonic-from-seed: allow arbitrary sized mnemonic --- keyfork-mnemonic-util/src/lib.rs | 3 ++- keyfork-plumbing/src/bin/keyfork-mnemonic-from-seed.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/keyfork-mnemonic-util/src/lib.rs b/keyfork-mnemonic-util/src/lib.rs index be413dc..3d535e2 100644 --- a/keyfork-mnemonic-util/src/lib.rs +++ b/keyfork-mnemonic-util/src/lib.rs @@ -149,7 +149,8 @@ impl FromStr for Mnemonic { None => return Err(MnemonicFromStrError::InvalidWord(index)), } } - if ![12, 24].contains(&words.len()) { + // 3 words for every 32 bits + if words.len() % 3 != 0 { return Err(MnemonicFromStrError::InvalidWordCount(words.len())); } Ok(Mnemonic { words, wordlist }) diff --git a/keyfork-plumbing/src/bin/keyfork-mnemonic-from-seed.rs b/keyfork-plumbing/src/bin/keyfork-mnemonic-from-seed.rs index f0b261e..a65a6a1 100644 --- a/keyfork-plumbing/src/bin/keyfork-mnemonic-from-seed.rs +++ b/keyfork-plumbing/src/bin/keyfork-mnemonic-from-seed.rs @@ -6,7 +6,7 @@ fn main() -> Result<(), Box> { input.read_line(&mut line)?; let decoded = smex::decode(line.trim())?; - let mnemonic = Mnemonic::from_entropy(&decoded, Default::default())?; + let mnemonic = unsafe { Mnemonic::from_raw_entropy(&decoded, Default::default()) }; println!("{mnemonic}");