@chainsafe/blst

中文文档
2.2.0发布于 2024/10/29Apache-2.0TypeScriptCommonJS零依赖构建来源已验证近 30 天下载 1.5万

Typescript wrapper for supranational/blst native bindings, a highly performant BLS12-381 signature library

原始使用文档
文档目录7 节
  1. Supported Environments
  2. Usage
  3. Spec versioning
  4. Contributing
  5. Release/Publishing
  6. Release
  7. License

blst-ts

ETH2.0_Spec_Version 1.4.0 ES Version Node Version

Typescript wrapper for supranational/blst native bindings, a highly performant BLS12-381 signature library.

Supported Environments

OS / Archbinary nameNode
Linux / x64linux-x6416, 18, 20, 21
Linux / arm64linux-arm6416, 18, 20, 21
Windows / x64win32-x6416, 18, 20, 21
macOS / x64darwin-x6416, 18, 20, 21
macOS / arm64darwin-arm6416, 18, 20, 21

Usage

yarn add @chainsafe/blst

This library comes with pre-compiled bindings for most platforms. You can check current support in releases. If your platform is not supported, bindings will be compiled from source as a best effort with node-gyp.

import crypto from "crypto";
import {SecretKey, verify, BLST_CONSTANTS} from "@chainsafe/blst";

const msg = Buffer.from("sample-msg");
const sk = SecretKey.fromKeygen(crypto.randomBytes(BLST_CONSTANTS.SECRET_KEY_LENGTH));
const pk = sk.toPublicKey();
const sig = sk.sign(msg);

console.log(verify(msg, pk, sig)); // true

This library exposes a classes for secret keys, public keys and signatures: SecretKey, PublicKey & Signature

The PublicKey and Signature contain an affine point (x,y) encoding of P1 in G1 and P2 in G2 respectively.

Spec versioning

This library has a hardcoded configuration compatible with Eth2.0 spec:

Settingvalue
PK_ING1
HASH_OR_ENCODEtrue
DSTBLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_
RAND_BITS64

spec

test vectors

Contributing

Please check out CONTRIBUTING.md for more info on how to use the repo and for architectural details

Release/Publishing

Release

The release process is automatically triggered when the master branch has the version in package.json updated.

To create a new release:

  1. Increment the project version in package.json
    • A pre-release can be published by ensuring that the project version is appended with non-numeric characters, eg: -beta
  2. run yarn run version
  3. merge a commit with these changes
  4. CI will run and result in a new release being published

License

Apache-2.0

版本与发布记录

@chainsafe/blst 共发布 27 个版本,首次发布于 2020/11/19;过去 12 个月发布了 0 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.2.0latest2024/10/292 年前
2.1.02024/10/222 年前
2.0.32024/07/262 年前
2.0.22024/07/262 年前
2.0.1next2024/07/222 年前
0.2.112024/06/052 年前

关于 @chainsafe/blst 的常见问题

@chainsafe/blst 是什么?

Typescript wrapper for supranational/blst native bindings, a highly performant BLS12-381 signature library

如何安装 @chainsafe/blst?

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

@chainsafe/blst 支持 TypeScript 吗?

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

@chainsafe/blst 支持 ESM 还是 CommonJS?

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

@chainsafe/blst 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >= 16。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@chainsafe/blst 可以商用吗?

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

@chainsafe/blst 的下载量有多少?

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

@chainsafe/blst 还在维护吗?

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