+
Skip to content

li0ard/bign

Repository files navigation

@li0ard/bign
Bign (STB 34.101.45) curves and DSA in pure TypeScript
docs




Installation

# from NPM
npm i @li0ard/bign

# from JSR
bunx jsr i @li0ard/bign

Supported modes:

  • DSA (standard curves included)

Features

  • Provides simple and modern API
  • Most of the APIs are strictly typed
  • Fully complies with STB 34.101.45 (in Russian) standard
  • Supports Bun, Node.js, Deno, Browsers

Examples

Create signature (Deterministic)

import { BIGN128, sign, verify, getPublicKey } from "@li0ard/bign";

let curve = BIGN128;
let privKey = hexToBytes("1F66B5B84B7339674533F0329C74F21834281FED0732429E0C79235FC273E269");
let publicKey = getPublicKey(curve, privKey);
let digest = hexToBytes("ABEF9725D4C5A83597A367D14494CC2542F20F659DDFECC961A3EC550CBA8C75");

let signature = sign(curve, privKey, digest);
console.log(signature); // -> Uint8Array [...]
console.log(verify(curve, publicKey, digest, signature)); // -> true

Create signature (Default)

import { SignMode, BIGN128, sign, verify, getPublicKey } from "@li0ard/bign";

let curve = BIGN128;
let privKey = hexToBytes("1F66B5B84B7339674533F0329C74F21834281FED0732429E0C79235FC273E269");
let publicKey = getPublicKey(curve, privKey);
let digest = hexToBytes("ABEF9725D4C5A83597A367D14494CC2542F20F659DDFECC961A3EC550CBA8C75");

let signature = sign(curve, privKey, digest, { mode: SignMode.DEFAULT });
console.log(signature); // -> Uint8Array [...]
console.log(verify(curve, publicKey, digest, signature)); // -> true

About

Bign (STB 34.101.45) curves and DSA in pure TypeScript

Topics

Resources

License

Stars

Watchers

Forks

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载