pub struct Mnemonic { /* private fields */ }mnemonic only.Expand description
A BIP-39 mnemonic phrase for key derivation.
§Example
use movement_sdk::account::Mnemonic;
// Generate a new mnemonic
let mnemonic = Mnemonic::generate(24).unwrap();
println!("Mnemonic: {}", mnemonic.phrase());
// Parse an existing mnemonic
let mnemonic = Mnemonic::from_phrase("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about").unwrap();Implementations§
Source§impl Mnemonic
impl Mnemonic
Sourcepub fn generate(word_count: usize) -> MovementResult<Self>
pub fn generate(word_count: usize) -> MovementResult<Self>
Sourcepub fn from_phrase(phrase: &str) -> MovementResult<Self>
pub fn from_phrase(phrase: &str) -> MovementResult<Self>
Creates a mnemonic from an existing phrase.
§Errors
Returns an error if the phrase is not a valid BIP-39 mnemonic.
Sourcepub fn to_seed(&self) -> MovementResult<[u8; 64]>
pub fn to_seed(&self) -> MovementResult<[u8; 64]>
Derives the seed from this mnemonic.
Uses an empty passphrase by default.
§Errors
Returns an error if the mnemonic cannot be re-parsed (should not happen since the phrase was validated during construction).
Sourcepub fn to_seed_with_passphrase(
&self,
passphrase: &str,
) -> MovementResult<[u8; 64]>
pub fn to_seed_with_passphrase( &self, passphrase: &str, ) -> MovementResult<[u8; 64]>
Derives the seed from this mnemonic with a passphrase.
§Errors
Returns an error if the mnemonic phrase cannot be re-parsed. This should never happen because the phrase is validated during construction, but returning an error is safer than panicking.
Sourcepub fn derive_ed25519_key(
&self,
index: u32,
) -> MovementResult<Ed25519PrivateKey>
Available on crate feature ed25519 only.
pub fn derive_ed25519_key( &self, index: u32, ) -> MovementResult<Ed25519PrivateKey>
ed25519 only.Derives an Ed25519 private key using the Movement derivation path.
Path: m/44'/637'/0'/0'/index'
§Errors
Returns an error if key derivation fails or the derived key is invalid.