💻 Javascript Implementation of Boneh-Lynn-Shacham Signatures
This repository has been archived on 2023-04-09. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Cayman 2932863392
Merge pull request #55 from ChainSafe/dapplion/deprecate-keypair
Deprecate IKeypair
2020-11-30 17:08:45 -07:00
.github Expose benchmark:all script 2020-11-30 22:07:26 +00:00
src Deprecate IKeypair 2020-12-01 00:07:45 +00:00
test Deprecate IKeypair 2020-12-01 00:07:45 +00:00
.babel-register Move to packages/bls 2019-08-05 10:48:26 -05:00
.babelrc Update dev delendencies, tests, linter 2020-02-20 14:51:25 -06:00
.eslintrc.js Fix lint issues 2020-11-25 11:50:47 +00:00
.gitignore Remove async from runForAllImplementations 2020-11-29 23:55:45 +00:00
.prettierignore Fix lint issues 2020-11-25 11:50:47 +00:00
.prettierrc.yml Fix prettier config file 2020-11-04 18:04:55 +00:00
CHANGELOG.md v5.0.0 2020-11-30 14:26:12 -06:00
LICENSE Move to packages/bls 2019-08-05 10:48:26 -05:00
README.md Update readme 2020-11-30 14:19:10 -06:00
blst-native.d.ts Export strategies 2020-11-25 15:03:15 +00:00
blst-native.js Export strategies 2020-11-25 15:03:15 +00:00
browser.d.ts Export strategies 2020-11-25 15:03:15 +00:00
browser.js Export strategies 2020-11-25 15:03:15 +00:00
herumi.d.ts Export strategies 2020-11-25 15:03:15 +00:00
herumi.js Export strategies 2020-11-25 15:03:15 +00:00
karma.conf.js Add named export test to browser test cases 2020-11-30 10:12:18 -06:00
node.d.ts Export strategies 2020-11-25 15:03:15 +00:00
node.js Export strategies 2020-11-25 15:03:15 +00:00
package.json Expose benchmark:all script 2020-11-30 22:07:26 +00:00
tsconfig.build.json Include tests in ts-config 2020-11-04 18:00:50 +00:00
tsconfig.json Ignore benchmark in tsconfig 2020-12-01 00:01:48 +00:00
webpack.config.js add bls browser test execution 2020-01-31 11:17:26 +01:00
yarn.lock Merge pull request #38 from ChainSafe/dependabot/npm_and_yarn/yargs-parser-13.1.2 2020-11-29 10:04:43 -07:00

README.md

bls

Build Status codecov ETH2.0_Spec_Version 1.0.0 ES Version Node Version

Javascript library for BLS (Boneh-Lynn-Shacham) signatures and signature aggregation, tailored for use in Eth2.

Usage

yarn add @chainsafe/bls

To use native bindings you must install peer dependency @chainsafe/blst

yarn add @chainsafe/bls @chainsafe/blst

You must initialize the library once in your application before using it. The result is cached and use across all your imports

import {init, SecretKey, secretKeyToPublicKey, sign, verify} from "@chainsafe/bls";

(async () => {
  await init("herumi");

  // class-based interface
  const secretKey = SecretKey.fromKeygen();
  const publicKey = secretKey.toPublicKey();
  const message = new Uint8Array(32);

  const signature = secretKey.sign(message);
  console.log("Is valid: ", signature.verify(publicKey, message));

  // functional interface
  const sk = secretKey.toBytes();
  const pk = secretKeyToPublicKey(sk);
  const sig = sign(sk, message);
  console.log("Is valid: ", verify(pk, message, sig));
})();

Browser

If you are in the browser, import from /browser to import directly the WASM version

import bls from "@chainsafe/bls/browser";

Native bindings only

If you are in NodeJS, import from /node to skip browser specific code. Also install peer dependency @chainsafe/blst which has the native bindings

yarn add @chainsafe/bls @chainsafe/blst
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. Also install peer dependency @chainsafe/blst which has the native bindings

yarn add @chainsafe/bls @chainsafe/blst
import {init} from "@chainsafe/bls";

try {
  await init("blst-native");
} catch (e) {
  await init("herumi");
  console.warn("Using WASM");
}

The API is identical for all implementations.

Spec versioning

Version Bls spec hash-to-curve version
5.x.x draft #9
2.x.x draft #7
1.x.x draft #6
0.3.x initial version

spec

test vectors

License

Apache-2.0