@chainsafe/bls-hd-key

中文文档
0.3.0发布于 2022/02/10Apache-2.0TypeScriptCommonJS近 30 天下载 2.2万

BLS KDF and HD wallet utilities

原始使用文档
文档目录4 节
  1. Example
  2. Contrubuting
  3. Audit
  4. License

BLS HD Key Utilities

npm (tag) Discord GitHub ES Version Node Version

Utility functions for managing BLS heirarchical deterministic accounts.

  1. Create a master private key from entropy
  2. Create a child private key from a private key and index
  3. Convert a standard path into an array of indices
  4. 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 "@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));

Contrubuting

Requirements:

  • nodejs
  • yarn
yarn install
yarn run test

Audit

This repo was audited by Least Authority as part of this security audit, released 2020-03-23. Commit 767c998 verified in the report.

License

Apache-2.0

版本与发布记录

@chainsafe/bls-hd-key 共发布 5 个版本,首次发布于 2019/12/01;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.3.0latest2022/02/104 年前
0.2.12021/04/215 年前
0.2.02020/09/276 年前
0.1.02020/07/306 年前
0.0.12019/12/016 年前

关于 @chainsafe/bls-hd-key 的常见问题

@chainsafe/bls-hd-key 是什么?

BLS KDF and HD wallet utilities

如何安装 @chainsafe/bls-hd-key?

在项目目录运行 npm install @chainsafe/bls-hd-key,或使用 pnpm add / yarn add / bun add。

@chainsafe/bls-hd-key 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@chainsafe/bls-hd-key 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@chainsafe/bls-hd-key 可以商用吗?

@chainsafe/bls-hd-key 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@chainsafe/bls-hd-key 的下载量有多少?

根据 npm 官方下载统计,@chainsafe/bls-hd-key 在 2026/10/10 – 2026/11/08 这 30 天内被下载 22,090 次,日均约 736 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@chainsafe/bls-hd-key 还在维护吗?

最新版本 0.3.0 发布于 2022/02/10(4 年前);至今共发布 5 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/12/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。