es-blst
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

ES-blst

ES and TypeScript wrapper around Wasm-built blst BLS12-381 signature library.

Requirements

ES2022 environment for asynchronous instantiating of the Wasm module during loading.

Build

Prerequisites

Clang >= 9.0 with wasm32 target available

MacOS

By default Homebrew doesn't link LLVM executables into its global executables directory which is usually listed in PATH. To build on MacOS you have to add LLVM directory (usually /opt/homebrew/opt/llvm/bin or /usr/local/opt/llvm/bin depending on Homebrew version) to PATH:

export PATH="/opt/homebrew/opt/llvm/bin:${PATH}"

The exact path will be printed after LLVM installation is finished.

Building

npm run init && npm run build

Example

import { MinPk } from "es-blst";

// generate a private key
const ikm = new Uint8Array(32);
crypto.getRandomValues(ikm);
const priv = MinPk.PrivateKey.generate(ikm);

// sign a message
const msg = new TextEncoder().encode("message text");
const sig = priv.sign(msg, "aug");

// derive a public key
const pub = priv.public();

// verify
const ok = sig.verify("aug", pub, msg);
console.log(ok);

Package Sidebar

Install

npm i es-blst

Weekly Downloads

2

Version

1.0.2

License

MIT

Unpacked Size

272 kB

Total Files

11

Last publish

Collaborators

  • mantischicory