[][src]Struct hkd32::KeyMaterial

pub struct KeyMaterial(_);

Cryptographic key material: 256-bit (32-byte) uniformly random bytestring generated either via a CSRNG or via hierarchical derivation.

This type provides the main key derivation functionality and is used to represent both input and output key material.


impl KeyMaterial[src]

pub fn random() -> Self[src]

Create random key material using the operating system CSRNG

pub fn from_bech32<S>(encoded: S) -> Result<(String, Self), Error> where
    S: AsRef<str>, 

Decode key material from a Bech32 representation

pub fn from_mnemonic<S>(phrase: S, language: Language) -> Result<Self, Error> where
    S: AsRef<str>, 

Create key material from a 24-word BIP39 mnemonic phrase

pub fn from_bytes(slice: &[u8]) -> Result<Self, Error>[src]

Create new key material from a byte slice.

Byte slice is expected to have been generated by a cryptographically secure random number generator.

pub fn new(bytes: [u8; 32]) -> KeyMaterial[src]

Import existing key material - must be uniformly random!

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

Borrow the key material as a byte slice

pub fn derive_subkey<P>(self, path: P) -> Self where
    P: AsRef<Path>, 

Derive an output key from the given input key material

pub fn to_bech32<S>(&self, hrp: S) -> Zeroizing<String> where
    S: AsRef<str>, 

Serialize this KeyMaterial as a self-zeroizing Bech32 string

Trait Implementations

impl From<[u8; 32]> for KeyMaterial[src]

impl From<Phrase> for KeyMaterial[src]

fn from(phrase: Phrase) -> KeyMaterial[src]

Convert to KeyMaterial using an empty password

impl<'a> TryFrom<&'a [u8]> for KeyMaterial[src]

type Error = Error

The type returned in the event of a conversion error.

impl Drop for KeyMaterial[src]

impl Clone for KeyMaterial[src]

impl Zeroize for KeyMaterial[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

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

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<Z> Zeroize for Z where
    Z: DefaultIsZeroes