Skip to main content

Mnemonic

Struct Mnemonic 

Source
pub struct Mnemonic { /* private fields */ }
Expand description

A BIP-39 mnemonic phrase.

Implementations§

Source§

impl Mnemonic

Source

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).

Source

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.

Source

pub fn from_phrase(phrase: &str) -> Result<Self, SignerError>

Parse a mnemonic phrase from a string.

Validates word count and checksum.

Source

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).

Source

pub fn phrase(&self) -> &str

Return the mnemonic phrase as a string.

Source

pub fn word_count(&self) -> usize

Return the number of words in the mnemonic.

Source

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}.

Source

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}.

Source

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.

Source

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}.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.