@iacobus/hd
Version:
Hierarchical Deterministic Symmetric Keys.
46 lines • 1.57 kB
TypeScript
/**
* @fileoverview Provides functionality for deriving hierarchical deterministic symmetric keys.
* @module
* @author Jacob V. B. Haap <iacobus.xyz>
* @license MIT
*/
import type { CHash } from "@noble/hashes/utils";
import type { HDPath } from "./path.js";
/** HDKey holds a Hierarchical Deterministic Key. */
export type HDKey = {
/** Cryptographic key. */
key: Uint8Array;
/** Chain code. */
code: Uint8Array;
/** Depth in hierarchy. */
depth: number;
/** Key fingerprint. */
fingerprint: Uint8Array;
};
/**
* deriveMaster derives a new master key from a given hash and secret.
* @example
* const master = deriveMaster(h, secret);
*/
export declare function deriveMaster(h: CHash, secret: Uint8Array): HDKey;
/**
* deriveChild derives a new child key from a given hash, master key, and index.
* @example
* const child = deriveChild(h, master, 42);
*/
export declare function deriveChild(h: CHash, master: HDKey, index: number): HDKey;
/**
* deriveNode derives a new key at a node in a hierarchy descending from a master key, from
* a given hash, master key, and derivation path.
* @example
* const node = deriveNode(h, master, path);
*/
export declare function deriveNode(h: CHash, master: HDKey, path: HDPath): HDKey;
/**
* lineage checks if a key is the direct child of a master key, from a given hash,
* child key, and master key.
* @example
* const related = lineage(h, child, master);
*/
export declare function lineage(h: CHash, child: HDKey, master: HDKey): boolean;
//# sourceMappingURL=key.d.ts.map