[go: up one dir, main page]

Enum bip39::keytype::KeyType [] [src]

pub enum KeyType {
    Key128,
    Key160,
    Key192,
    Key224,
    Key256,
}

Variants

Methods

impl KeyType
[src]

Create a new KeyType struct for a specific key size

This allows code to request key types for arbitrary key lengths, rather than pattern matching on their own.

Note that specifying a bit length not provided for by BIP0039 will return an error.

Example

use bip39::{KeyType};

let kt = KeyType::for_keysize(128).unwrap();

Create a new KeyType struct for a specific phrase length

This allows code to request key types for arbitrary word lengths rather than pattern matching on their own.

Note that specifying a word length not provided for by BIP0039 will return an error.

Example

use bip39::{KeyType};

let kt = KeyType::for_word_length(12).unwrap();

Get a KeyType struct matching an existing BIP0039 phrase

This allows code to get information about a mnemonic phrase, like the entropy value of the seed that can be generated from it

Example

use bip39::{KeyType};

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

let key_type = KeyType::for_mnemonic(test_mnemonic).unwrap();

let entropy_bits = key_type.entropy_bits();

Return the number of entropy+checksum bits for this key type

Example

use bip39::{KeyType};

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

let key_type = KeyType::for_mnemonic(test_mnemonic).unwrap();

let total_bits = key_type.total_bits();

Return the number of entropy bits for this key type

Example

use bip39::{KeyType};

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

let key_type = KeyType::for_mnemonic(test_mnemonic).unwrap();

let entropy_bits = key_type.entropy_bits();

Return the number of checksum bits for this key type

Example

use bip39::{KeyType};

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

let key_type = KeyType::for_mnemonic(test_mnemonic).unwrap();

let checksum_bits = key_type.checksum_bits();

Return the proper number of words for this key type

Example

use bip39::{KeyType};

let key_type = KeyType::Key128;

let word_length = key_type.word_length();

Trait Implementations

impl Debug for KeyType
[src]

Formats the value using the given formatter.