keyfork-mnemonic-from-seed: allow arbitrary sized mnemonic

This commit is contained in:
Ryan Heywood 2023-12-26 18:07:56 -05:00
parent 2670cf63a3
commit 55b41a49ef
Signed by: ryan
GPG Key ID: 8E401478A3FBEF72
2 changed files with 3 additions and 2 deletions

View File

@ -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 })

View File

@ -6,7 +6,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
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}");