UNPKG

@iacobus/hd

Version:

Hierarchical Deterministic Symmetric Keys.

70 lines 2.34 kB
/** * @fileoverview Entry point for @iacobus/hd. * Exports the Hdsk class, which exposes functionality for symmetric hierarchical * deterministic key derivation, including master key derivation and schema-enforced * derivation path parsing. * @module * @author Jacob V. B. Haap <iacobus.xyz> * @license MIT */ import type { CHash } from "@noble/hashes/utils"; import { type HDSchema, type HDPath } from "./path.js"; import { type HDKey } from "./key.js"; /** Schema is an instance of a derivation path schema. */ export declare class Schema { schema: HDSchema; constructor(str: string); /** * parse parses a new derivation path from a given hash and string. * @example * const path = Schema.parse(h, "m/42/0/1/0"); */ parse(h: CHash, str: string): HDPath; } /** Key is an instance of an HD key. */ export declare class Key { key: HDKey; h: CHash; constructor(h: CHash, key: HDKey); /** * child derives a new child key from a given index. * @example * const child = Key.child(42); */ child(index: number): Key; /** * node derives a new key at a specific node in a hierarchy in * relation to a master key, from a given derivation path. * @example * const node = Key.node(path); */ node(path: HDPath): Key; /** * lineage checks if a key is the direct child of a master key, * from a given hash master key. * @example * const related = Key.lineage(master.key); */ lineage(master: HDKey): boolean; } /** * Hdsk exposes functionality for hierarchical deterministic symmetric key derivation. * It provides methods to derive master keys and parse derivation path schemas, used to * initialize key hierarchies, and parse schema-enforced derivation paths. */ export declare class Hdsk { /** * schema parses a new derivation path schema from a given string. * @example * const str: string = "m / application: any / purpose: any / context: any / index: num"; * const schema = new Hdsk().schema(str); */ schema(str: string): Schema; /** * master derives a new master key from a given hash and secret. * @example * const master = new Hdsk().master(h, secret); */ master(h: CHash, secret: Uint8Array): Key; } //# sourceMappingURL=mod.d.ts.map