pub enum KeyPhraseType {
Words12 = 32_772,
Words15 = 40_965,
Words18 = 49_158,
Words21 = 57_351,
Words24 = 65_544,
}Expand description
Determines the number of words that will be present in a KeyPhrase phrase
Also directly affects the amount of entropy that will be used to create a KeyPhrase,
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 keyphrase is essentially a friendly representation of a 128-bit key, while a 24 word keyphrase is essentially a 256-bit key.
If you know you want a specific phrase length, you can use the enum variant directly, for example
KeyPhraseType::Words12.
You can also get a KeyPhraseType that corresponds to one of the standard BIP39 key sizes by
passing arbitrary usize values:
use keyphrase::{KeyPhraseType};
let keyphrase_type = KeyPhraseType::for_key_size(128).unwrap();Variants§
Implementations§
Source§impl KeyPhraseType
impl KeyPhraseType
Sourcepub fn for_word_count(size: usize) -> Result<KeyPhraseType, Error>
pub fn for_word_count(size: usize) -> Result<KeyPhraseType, Error>
Get a KeyPhraseType for a keyphrase 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 keyphrase::{KeyPhraseType};
let keyphrase_type = KeyPhraseType::for_word_count(12).unwrap();Sourcepub fn for_key_size(size: usize) -> Result<KeyPhraseType, Error>
pub fn for_key_size(size: usize) -> Result<KeyPhraseType, Error>
Get a KeyPhraseType for a keyphrase 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 keyphrase::{KeyPhraseType};
let keyphrase_type = KeyPhraseType::for_key_size(128).unwrap();Sourcepub fn for_phrase(phrase: &str) -> Result<KeyPhraseType, Error>
pub fn for_phrase(phrase: &str) -> Result<KeyPhraseType, Error>
Get a KeyPhraseType for an existing keyphrase
This can be used when you need information about a keyphrase based on the number of
words, for example you can get the entropy value using KeyPhraseType::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 keyphrase::{KeyPhraseType};
let test_keyphrase = "park remain person kitchen mule spell knee armed position rail grid ankle";
let keyphrase_type = KeyPhraseType::for_phrase(test_keyphrase).unwrap();
let entropy_bits = keyphrase_type.entropy_bits();Sourcepub fn total_bits(self) -> usize
pub fn total_bits(self) -> usize
Return the number of entropy+checksum bits
§Example
use keyphrase::{KeyPhraseType};
let test_keyphrase = "park remain person kitchen mule spell knee armed position rail grid ankle";
let keyphrase_type = KeyPhraseType::for_phrase(test_keyphrase).unwrap();
let total_bits = keyphrase_type.total_bits();Sourcepub fn entropy_bits(self) -> usize
pub fn entropy_bits(self) -> usize
Return the number of entropy bits
§Example
use keyphrase::{KeyPhraseType};
let test_keyphrase = "park remain person kitchen mule spell knee armed position rail grid ankle";
let keyphrase_type = KeyPhraseType::for_phrase(test_keyphrase).unwrap();
let entropy_bits = keyphrase_type.entropy_bits();Sourcepub fn checksum_bits(self) -> u8
pub fn checksum_bits(self) -> u8
Return the number of checksum bits
§Example
use keyphrase::{KeyPhraseType};
let test_keyphrase = "park remain person kitchen mule spell knee armed position rail grid ankle";
let keyphrase_type = KeyPhraseType::for_phrase(test_keyphrase).unwrap();
let checksum_bits = keyphrase_type.checksum_bits();Sourcepub fn word_count(self) -> usize
pub fn word_count(self) -> usize
Return the number of words
§Example
use keyphrase::{KeyPhraseType};
let keyphrase_type = KeyPhraseType::Words12;
let word_count = keyphrase_type.word_count();Trait Implementations§
Source§impl Clone for KeyPhraseType
impl Clone for KeyPhraseType
Source§fn clone(&self) -> KeyPhraseType
fn clone(&self) -> KeyPhraseType
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more