pub struct Mnemonic { /* private fields */ }Expand description
A BIP-39 mnemonic phrase.
Implementations§
Source§impl Mnemonic
impl Mnemonic
Sourcepub fn generate(word_count: usize) -> Result<Self, SignerError>
pub fn generate(word_count: usize) -> Result<Self, SignerError>
Generate a new random mnemonic with the given word count.
Supported counts: 12 (128-bit), 15 (160-bit), 18 (192-bit), 21 (224-bit), 24 (256-bit).
Sourcepub fn from_entropy(entropy: &[u8]) -> Result<Self, SignerError>
pub fn from_entropy(entropy: &[u8]) -> Result<Self, SignerError>
Create a mnemonic from raw entropy bytes.
Entropy length must be 16, 20, 24, 28, or 32 bytes.
Sourcepub fn from_phrase(phrase: &str) -> Result<Self, SignerError>
pub fn from_phrase(phrase: &str) -> Result<Self, SignerError>
Parse a mnemonic phrase from a string.
Validates word count and checksum.
Sourcepub fn to_seed(&self, passphrase: &str) -> Zeroizing<[u8; 64]>
pub fn to_seed(&self, passphrase: &str) -> Zeroizing<[u8; 64]>
Convert the mnemonic to a 64-byte seed using PBKDF2-SHA512.
The passphrase is optional (use "" for no passphrase).
Sourcepub fn word_count(&self) -> usize
pub fn word_count(&self) -> usize
Return the number of words in the mnemonic.
Sourcepub fn to_ethereum_signer(
&self,
passphrase: &str,
account_index: u32,
) -> Result<EthereumSigner, SignerError>
pub fn to_ethereum_signer( &self, passphrase: &str, account_index: u32, ) -> Result<EthereumSigner, SignerError>
Derive an Ethereum signer from this mnemonic.
Uses BIP-44 path m/44'/60'/0'/0/{account_index}.
Sourcepub fn to_bitcoin_signer(
&self,
passphrase: &str,
account_index: u32,
) -> Result<BitcoinSigner, SignerError>
pub fn to_bitcoin_signer( &self, passphrase: &str, account_index: u32, ) -> Result<BitcoinSigner, SignerError>
Derive a Bitcoin signer from this mnemonic.
Uses BIP-44 path m/44'/0'/0'/0/{account_index}.
Sourcepub fn to_solana_signer(
&self,
passphrase: &str,
account_index: u32,
) -> Result<SolanaSigner, SignerError>
pub fn to_solana_signer( &self, passphrase: &str, account_index: u32, ) -> Result<SolanaSigner, SignerError>
Derive a Solana signer from this mnemonic.
Uses BIP-44 path m/44'/501'/{account_index}'/0'.
Note: Solana uses Ed25519, but BIP-32 derives secp256k1 keys. This returns the raw 32-byte derived key as the Ed25519 seed, which is the convention used by Phantom and other Solana wallets.
Sourcepub fn to_xrp_signer(
&self,
passphrase: &str,
account_index: u32,
) -> Result<XrpEcdsaSigner, SignerError>
pub fn to_xrp_signer( &self, passphrase: &str, account_index: u32, ) -> Result<XrpEcdsaSigner, SignerError>
Derive an XRP ECDSA signer from this mnemonic.
Uses BIP-44 path m/44'/144'/0'/0/{account_index}.