# @chainsafe/bls-keystore 中文文档

规范地址：https://npmcn.com/package/%40chainsafe/bls-keystore/

版本：3\.1\.0
npm 元数据更新时间：2026-04-21T09:50:47.490Z
中文译文更新时间：2026-11-09T09:35:54.256Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40chainsafe/bls-keystore
原文对照：https://npmcn.com/package/%40chainsafe/bls-keystore/?lang=original
源码仓库：https://github.com/ChainSafe/bls-keystore

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：113 kB，39 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- 运行依赖：2 个
- 首次发布：2020-02-10T21:21:52.912Z
- 最新版本发布：2024-07-15T21:21:06.473Z
- 近 30 天下载量：14858（2026-10-10 至 2026-11-08，npm 官方下载统计）
- 已发布版本数：6（近 12 个月 0 个）

## 中文简介

![npm](https://img.shields.io/npm/v/@ChainSafe/bls-keystore) ![Discord](https://img.shields.io/discord/593655374469660673?color=blue&label=Discord&logo=discord) \[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)\[(\][https://opensource.org/ 互联网档案馆的存檔,存档日期2013-12-21](https://opensource.org/)

## 安装

```sh
npm install @chainsafe/bls-keystore
```

也可以使用：`pnpm add @chainsafe/bls-keystore`、`yarn add @chainsafe/bls-keystore`、`bun add @chainsafe/bls-keystore`

## README

# @ChanSafe/ bls- keystore (中文(简体) )

![npm](https://img.shields.io/npm/v/@ChainSafe/bls-keystore) ![Discord](https://img.shields.io/discord/593655374469660673?color=blue&label=Discord&logo=discord) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) ![es-version](https://img.shields.io/badge/ES-2015-yellow) ![node-version](https://img.shields.io/badge/node-10.x-green)

> 字型执行 [EIP 2335](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2335.md) 用于节点和浏览器.

### 怎样用?

功能接口

```typescript
import {Buffer} from "buffer";
import {
  IKeystore,
  create,
  decrypt,
  verifyPassword,
  isValidKeystore,
  validateKeystore,
} from "@chainsafe/bls-keystore";

// encrypt private key
const password: string | Uint8Array = "SomePassword123"; 
const privateKey: Uint8Array = ...;
const publicKey: Uint8Array = ...;
const path: string = "m/12381/60/0/0";

// keystore is an `object` that follows the EIP-2335 schema
const keystore: IKeystore = await create(password, privateKey, publicKey, path);

// verify password
await verifyPassword(keystore, password); //true | false

// decrypt
const decryptedPrivateKey: Buffer = await decrypt(keystore, password);

// convert to string
JSON.stringify(keystore); //string

// determine if unsanitized data fits the EIP-2335 schema
const data: unknown = ...;
isValidKeystore(data); // true | false

validateKeystore(data); // throws if invalid
```

基于类的接口

```typescript
import {Buffer} from "buffer";
import {
  Keystore,
} from "@chainsafe/bls-keystore";

// encrypt private key
const password: string | Uint8Array = "SomePassword123"; 
const privateKey: Uint8Array = ...;
const publicKey: Uint8Array = ...;
const path: string = "m/12381/60/0/0";

// keystore is a `Keystore` instance that follows the EIP-2335 schema with additional convenience methods
const keystore: Keystore = await Keystore.create(password, privateKey, publicKey, path);

// verify password
await keystore.verifyPassword(password); //true | false

// decrypt
const decryptedPrivateKey: Buffer = await keystore.decrypt(password);

// convert to string
keystore.stringify(); //string

// determine if unsanitized data fits the EIP-2335 schema
const data: unknown = ...;
Keystore.fromObject(data); // returns a Keystore or throws if data is invalid
```

对于密钥导出检出 [@ 链条安全/ bls- keygen](https://github.com/ChainSafe/bls-keygen)

### 贡献

-   获取线条
-   线条安装
-   纱线测试

## 常见问题

### @chainsafe/bls-keystore 是什么？

\[\[\(\]https://opensource\.org/ 互联网档案馆的存檔,存档日期2013-12-21

### 如何安装 @chainsafe/bls-keystore？

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

### @chainsafe/bls-keystore 支持 TypeScript 吗？

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

### @chainsafe/bls-keystore 支持 ESM 还是 CommonJS？

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

### @chainsafe/bls-keystore 可以商用吗？

@chainsafe/bls-keystore 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @chainsafe/bls-keystore 的下载量有多少？

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

### @chainsafe/bls-keystore 还在维护吗？

最新版本 3\.1\.0 发布于 2024/07/16（2 年前）；至今共发布 6 个版本，其中过去 12 个月发布了 0 个；首次发布于 2020/02/11。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

