BLS HD 密钥公用事业
用于管理 BLS 继承式决定性账户的功能 .
- 从 Entropy 创建主密钥
- 从私钥和索引创建儿童私钥
- 将标准路径转换成一系列索引
- 从私人密钥和一系列指数中创建一个失真私钥
执行方式如下: EIP-2334, (中文(简体) ), EIP-2333
关于更高层次的界面,参见 @ 链条安全/ bls- keygen。 。 。 .
示例
import {deriveMasterSK, deriveChildSK, deriveChildSKMultiple, pathToIndices} from "@chainsafe/bls-hd-key";
// Create master private key (according to EIP-2333)
const entropy: Uint8Array = Uint8Array.from(...);
const masterKey: Uint8Array = deriveMasterSK(entropy);
// Create child private key one level deep
const childIndex: number = ...;
const childKey: Uint8Array = deriveChildSK(masterKey, childIndex);
// Convert a "path" into an array of indices (using validation rules of EIP-2334)
cont path = "m/12381/3600/0/0";
const childIndices: number[] = pathToIndices(path);
// Convert a "path" into an array of indices (validating an alternate key type)
const eth1KeyType = 60;
cont path = "m/12381/60/0/0";
const childIndices: number[] = pathToIndices(path, eth1KeyType);
// Create a child private key `childIndices.length` levels deep
const childIndices: number[] = [...];
const childKey = deriveChildSKMultiple(masterKey, childIndices);
// Compose functions to derive a child key from entropy and a path
const entropy: Uint8Array = Uint8Array.from(...);
cont path = "m/12381/3600/0/0";
const childKey = deriveChildSKMultiple(deriveMasterSK(entropy), pathToIndices(path));
争吵
所需经费:
- 节点
- 线条
yarn install
yarn run test
审计
这一回购额由最不发达国家管理局审计,作为 本次安全审计,于2020-03-23发布. 提交 767c998 报告已核实.
许可证
阿帕奇 - 2.0