BLS HD Key Utilities
Utility functions for managing BLS heirarchical deterministic accounts.
- Create a master private key from entropy
- Create a child private key from a private key and index
- Convert a standard path into an array of indices
- Create a decendent private key from a private key and array of indices
Implementation is following EIPS: EIP-2334, EIP-2333
For a higher-level interface, see @chainsafe/bls-keygen.
Example
import {deriveMasterSK, deriveChildSK, deriveChildSKMultiple, pathToIndices} from "bls-hd-key";
const entropy: Buffer = Buffer.from(...);
const masterKey: Buffer = deriveMasterSK(entropy);
const childIndex: number = ...;
const childKey: Buffer = deriveChildSK(masterKey, childIndex);
cont path = "m/12381/3600/0/0";
const childIndices: number[] = pathToIndices(path);
const eth1KeyType = 60;
cont path = "m/12381/60/0/0";
const childIndices: number[] = pathToIndices(path, eth1KeyType);
const childIndices: number[] = [...];
const childKey = deriveChildSKMultiple(masterKey, childIndices);
const entropy: Buffer = Buffer.from(...);
cont path = "m/12381/3600/0/0";
const childKey = deriveChildSKMultiple(deriveMasterSK(entropy), pathToIndices(path));
Contrubuting
Requirements:
yarn install
yarn run test
License
Apache-2.0