@digitalbazaar/bbs-signatures

中文文档
3.1.0发布于 2026/06/02BSD-3-ClauseES Module近 30 天下载 2万

A JavasSript BBS Signatures Implementation

原始使用文档
文档目录13 节
  1. Table of Contents
  2. Background
  3. Security
  4. Install
  5. Usage
  6. Generating a new public/secret key pair
  7. Creating a BBS signature
  8. Verifying a BBS signature
  9. Creating a BBS proof
  10. Verifying a BBS proof
  11. Contribute
  12. Commercial Support
  13. License

BBS Signatures (@digitalbazaar/bbs-signatures)

Node.js CI NPM Version

A JavaScript BBS Signatures Implementation

Table of Contents

Background

See also (related specs):

Security

As with most security- and cryptography-related tools, the overall security of your system will largely depend on your design decisions.

Install

  • Node.js 18+ is required.

To install locally (for development):

git clone https://github.com/digitalbazaar/bbs-signatures.git
cd bbs-signatures
npm install

Usage

Generating a new public/secret key pair

To generate a new public/secret BLS12-381 key pair for use with BBS signatures:

import * as bbs from '@digitalbazaar/bbs-signatures';

const {secretKey, publicKey} = await bbs.generateKeyPair({
  ciphersuite: 'BLS12-381-SHA-256'
  // same as using the constant: bbs.CIPHERSUITES.BLS12381_SHA256
});
// includes `secretKey` and `publicKey` keys, each is a `Uint8Array`
// `secretKey` is big-endian-encoded scalar
// `publicKey` is compressed (x, y) coordinates of a BLS12-381 G2 point
// other ciphersuite choice is: 'BLS12-381-SHAKE-256'

Creating a BBS signature

Sign an optional header and an array of messages using BBS.

import * as bbs from '@digitalbazaar/bbs-signatures';

const {secretKey, publicKey} = await bbs.generateKeyPair({
  ciphersuite: 'BLS12-381-SHA-256'
});
// `header`
const header = new Uint8Array();
// N-many `messages`, each is a `Uint8Array`, use `TextEncoder` to
// express strings as UTF-8 bytes
const messages = [new TextEncoder().encode('some message')];
// `signature` is a `Uint8Array`
const signature = await bbs.sign({secretKey, publicKey, header, messages});

Verifying a BBS signature

Verify a full BBS signature. This verification method is less likely to be used than verifyProof() as holders of signatures are expected to derive proofs for verification by verifiers.

import * as bbs from '@digitalbazaar/bbs-signatures';

// pass original signer's `publicKey`, `signature`, `header`, and `messages`
const verified = await bbs.verifySignature({
  publicKey, signature, header, messages,
  ciphersuite: 'BLS12-381-SHA-256'
});
// `verified` is a boolean

Creating a BBS proof

Derive a proof from a BBS signature as a holder / prover.

import * as bbs from '@digitalbazaar/bbs-signatures';

// pass original signer's `publicKey`, `signature`, `header`, and `messages`
// as well as a custom `presentationHeader` and any `disclosedMessageIndexes`
const proof = await bbs.deriveProof({
  publicKey, signature, header, messages,
  presentationHeader, disclosedMessageIndexes,
  ciphersuite: 'BLS12-381-SHA-256'
});
// `proof` is a `Uint8Array` containing a BBS proof

Verifying a BBS proof

Verify a proof from a holder / prover.

import * as bbs from '@digitalbazaar/bbs-signatures';

// pass `proof`, original signer's `publicKey` and`header`
// as well as holder's custom `presentationHeader`, `disclosedMessages`, and
// `disclosedMessageIndexes`
const verified = await bbs.verifyProof({
  publicKey, proof, header,
  presentationHeader, disclosedMessages, disclosedMessageIndexes,
  ciphersuite: 'BLS12-381-SHA-256'
});
// `verified` is a boolean

Contribute

See the contribute file!

PRs accepted.

If editing the Readme, please conform to the standard-readme specification.

Commercial Support

Commercial support for this library is available upon request from Digital Bazaar: [email protected]

License

New BSD License (3-clause) © 2024 Digital Bazaar

版本与发布记录

@digitalbazaar/bbs-signatures 共发布 7 个版本,首次发布于 2024/01/10;过去 12 个月发布了 1 个版本。

版本发布日期距今
3.1.0latest2026/06/025 个月前
3.0.02024/08/202 年前
2.1.02024/01/122 年前
2.0.02024/01/112 年前
1.2.02024/01/112 年前
1.1.02024/01/112 年前

关于 @digitalbazaar/bbs-signatures 的常见问题

@digitalbazaar/bbs-signatures 是什么?

A JavasSript BBS Signatures Implementation

如何安装 @digitalbazaar/bbs-signatures?

在项目目录运行 npm install @digitalbazaar/bbs-signatures,或使用 pnpm add / yarn add / bun add。

@digitalbazaar/bbs-signatures 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/digitalbazaar__bbs-signatures 是否存在。

@digitalbazaar/bbs-signatures 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@digitalbazaar/bbs-signatures 需要什么版本的 Node.js?

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

@digitalbazaar/bbs-signatures 可以商用吗?

@digitalbazaar/bbs-signatures 使用 BSD-3-Clause 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。另外不得用原作者名义为衍生产品背书。以上为概括,不构成法律意见,请以许可原文为准。

@digitalbazaar/bbs-signatures 的下载量有多少?

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

@digitalbazaar/bbs-signatures 还在维护吗?

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