crypto_wallet_gen/mnemonics/mod.rs
1use anyhow::Result;
2
3use crate::bip32::HDPrivKey;
4
5pub trait MnemonicFactory: Sized {
6 fn generate() -> Result<Self>;
7 fn from_phrase(phrase: &str) -> Result<Self>;
8
9 /// Validate a mnemonic phrase
10 ///
11 /// The phrase supplied will be checked for word length and validated according to the checksum
12 /// specified in BIP0039.
13 fn validate(phrase: &str) -> Result<()>;
14}
15
16pub trait Mnemonic {
17 fn phrase(&self) -> &str;
18 fn into_phrase(self) -> String;
19 fn to_private_key(&self, password: &str) -> Result<HDPrivKey>;
20}
21
22pub mod bip39;
23pub mod scrypt;