[][src]Enum bip39_rs::MnemonicType

pub enum MnemonicType {
    Words12,
    Words15,
    Words18,
    Words21,
    Words24,
}

Determines the number of words that will be present in a Mnemonic phrase

Also directly affects the amount of entropy that will be used to create a Mnemonic, and therefore the cryptographic strength of the HD wallet keys/addresses that can be derived from it using the Seed.

For example, a 12 word mnemonic phrase is essentially a friendly representation of a 128-bit key, while a 24 word mnemonic phrase is essentially a 256-bit key.

If you know you want a specific phrase length, you can use the enum variant directly, for example MnemonicType::Words12.

You can also get a MnemonicType that corresponds to one of the standard BIP39 key sizes by passing arbitrary usize values:

use bip39::{MnemonicType};

let mnemonic_type = MnemonicType::for_key_size(128).unwrap();

Variants

Words12Words15Words18Words21Words24

Methods

impl MnemonicType[src]

pub fn for_word_count(size: usize) -> Result<MnemonicType, Error>[src]

Get a MnemonicType for a mnemonic phrase with a specific number of words

Specifying a word count not provided for by the BIP39 standard will return an Error of kind ErrorKind::InvalidWordLength.

Example

use bip39::{MnemonicType};

let mnemonic_type = MnemonicType::for_word_count(12).unwrap();

pub fn for_key_size(size: usize) -> Result<MnemonicType, Error>[src]

Get a MnemonicType for a mnemonic phrase representing the given key size as bits

Specifying a key size not provided for by the BIP39 standard will return an Error of kind ErrorKind::InvalidKeysize.

Example

use bip39::{MnemonicType};

let mnemonic_type = MnemonicType::for_key_size(128).unwrap();

pub fn for_phrase(phrase: &str) -> Result<MnemonicType, Error>[src]

Get a MnemonicType for an existing mnemonic phrase

This can be used when you need information about a mnemonic phrase based on the number of words, for example you can get the entropy value using MnemonicType::entropy_bits.

Specifying a phrase that does not match one of the standard BIP39 phrase lengths will return an Error of kind ErrorKind::InvalidWordLength. The phrase will not be validated in any other way.

Example

use bip39::{MnemonicType};

let test_mnemonic = "park remain person kitchen mule spell knee armed position rail grid ankle";

let mnemonic_type = MnemonicType::for_phrase(test_mnemonic).unwrap();

let entropy_bits = mnemonic_type.entropy_bits();

pub fn total_bits(&self) -> usize[src]

Return the number of entropy+checksum bits

Example

use bip39::{MnemonicType};

let test_mnemonic = "park remain person kitchen mule spell knee armed position rail grid ankle";

let mnemonic_type = MnemonicType::for_phrase(test_mnemonic).unwrap();

let total_bits = mnemonic_type.total_bits();

pub fn entropy_bits(&self) -> usize[src]

Return the number of entropy bits

Example

use bip39::{MnemonicType};

let test_mnemonic = "park remain person kitchen mule spell knee armed position rail grid ankle";

let mnemonic_type = MnemonicType::for_phrase(test_mnemonic).unwrap();

let entropy_bits = mnemonic_type.entropy_bits();

pub fn checksum_bits(&self) -> u8[src]

Return the number of checksum bits

Example

use bip39::{MnemonicType};

let test_mnemonic = "park remain person kitchen mule spell knee armed position rail grid ankle";

let mnemonic_type = MnemonicType::for_phrase(test_mnemonic).unwrap();

let checksum_bits = mnemonic_type.checksum_bits();

pub fn word_count(&self) -> usize[src]

Return the number of words

Example

use bip39::{MnemonicType};

let mnemonic_type = MnemonicType::Words12;

let word_count = mnemonic_type.word_count();

Trait Implementations

impl Copy for MnemonicType[src]

impl Default for MnemonicType[src]

impl Clone for MnemonicType[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Display for MnemonicType[src]

impl Debug for MnemonicType[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From for T[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Same for T

type Output = T

Should always be Self