1.8 KiB
1.8 KiB
bls
Javascript library for BLS (Boneh-Lynn-Shacham) signatures and signature aggregation.
Usage
import {PrivateKey} from "@chainsafe/bls";
const secretKey = PrivateKey.fromKeygen();
const publicKey = secretKey.toPublicKey();
const message = new Uint8Array(32);
const signature = secretKey.sign(message);
console.log("Is valid: ", signature.verify(publicKey, message));
Browser
If you are in the browser, import from /browser
import bls from "@chainsafe/bls/browser";
Native bindings only
If you are in NodeJS, import from /node
to skip browser specific code
import bls from "@chainsafe/bls/node";
Native bindings + WASM fallback
If you want to offer a fallback in NodeJS, first try to load native bindings and then fallback to WASM
import bls from "@chainsafe/bls";
try {
await bls.init("blst-native");
} catch (e) {
await bls.init("herumi");
console.warn("Using WASM");
}
The API is identical for all implementations.
Spec versioning
Version | Bls spec version |
---|---|
2.x.x | draft #7 |
1.x.x | draft #6 |
0.3.x | initial version |
License
Apache-2.0