BBS 签名 (@digitalbazaar/bbs-signers)
一个 JavaScript BBS 签名执行
目录
背景情况
另见(相关规格):
警卫
同大多数与安全和密码学有关的工具一样 您的系统将在很大程度上取决于您的设计决定 .
安装
- 需要节点.js 18+.
在当地安装(用于开发):
git clone https://github.com/digitalbazaar/bbs-signatures.git
cd bbs-signatures
npm install
使用量
生成新的公密密钥配对
要生成一个新的公用/保密的 BLS12-381 密钥配对, 并使用 BBS 签名 :
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'
创建 BBS 签名
签名可选 header 和一组 messages 使用 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});
正在验证 BBS 签名
验证完整的 BBS 签名 。 这种核查方法不太可能
用于 verifyProof() 签字持有人应
供核查者核实的证据.
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
创建 BBS 证明
从 BBS 签名中获取作为持有者/验证者的证据 .
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
正在验证 BBS 证明
验证持有者/ 验证者提供的证据 .
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
贡献
见 贡献文件来啊!
公关接受.
请遵照 标准读取 规格.
商业支助
该图书馆的商务支助可应下列请求提供: 数字集市: 支持@ digitalbazaar.com
许可证
新建 BSD 许可证( 3- clause) 2024年数字集市