Enum bip39::keytype::KeyType
[−]
[src]
pub enum KeyType {
Key128,
Key160,
Key192,
Key224,
Key256,
}Variants
Key128Key160Key192Key224Key256Methods
impl KeyType[src]
fn for_keysize(size: usize) -> Result<KeyType, Bip39Error>
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();
fn for_word_length(length: usize) -> Result<KeyType, Bip39Error>
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();
fn for_mnemonic<S>(mnemonic: S) -> Result<KeyType, Bip39Error> where
S: Into<String>,
S: Into<String>,
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();
fn total_bits(&self) -> usize
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();
fn entropy_bits(&self) -> usize
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();
fn checksum_bits(&self) -> usize
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();
fn word_length(&self) -> usize
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();