[−][src]Crate hkd32
HMAC-based Hierarchical Key Derivation: deterministically derive a hierarchy of symmetric keys from initial keying material through repeated applications of the Hash-based Message Authentication Code (HMAC) construction.
This library implements a fully symmetric construction inspired by BIP-0032: Hierarchical Deterministic Wallets.
Usage
To derive a key using HKD32, you'll need the following:
hkd32::KeyMaterial
: a 32-byte (256-bit) uniformly random valuehkd32::Path
orhkd32::PathBuf
: path to the child key
Derivation paths can be raw bytestrings but also support a Unix path-like
syntax which can be parsed using the String::parse
method:
let path = "/foo/bar/baz".parse::<hkd32::PathBuf>().unwrap();
Example
// Parent key let input_key_material = hkd32::KeyMaterial::random(); // Path to the child key let derivation_path = "/foo/bar/baz".parse::<hkd32::PathBuf>().unwrap(); // Derive subkey from the parent key. Call `as_bytes()` on this to obtain // a byte slice containing the derived key. let output_key_material = input_key_material.derive_subkey(derivation_path);
Modules
mnemonic | Support for BIP39 mnemonic phrases. |
Structs
Component | Component of a derivation path |
Components | Iterator over the components of a path |
Error | Opaque error type |
KeyMaterial | Cryptographic key material: 256-bit (32-byte) uniformly random bytestring generated either via a CSRNG or via hierarchical derivation. |
Path | Key derivation paths: location within a key hierarchy which names/identifies a specific key. |
PathBuf | Key derivation paths: location within a key hierarchy which names/identifies a specific key. |
Constants
DELIMITER | Delimiter used for strings containing paths |
KEY_SIZE | Size of input key material and derived keys. |
MAX_COMPONENT_LENGTH | Maximum length of a derivation component |