UNPKG

navio-blsct

Version:

TypeScript bindings for the `libblsct` library used by the [Navio](https://nav.io/) blockchain to construct confidential transactions based on the BLS12-381 curve.

33 lines (24 loc) 673 B
import { Signature } from '../signature' import { Scalar } from '../scalar' import { PublicKey } from '../keys/publicKey' const msg = 'navio' const privKey = Scalar.random() const getInstance = (): Signature => { return Signature.generate(privKey, msg) } test('generate', () => { getInstance() }) test('vefiry', () => { const pubKey = PublicKey.fromScalar(privKey) const sig = getInstance() const res = sig.verify(pubKey, msg) expect(res).toBe(true) }) test('serialize and deserialize', () => { const a = getInstance() const a_hex = a.serialize() const b = Signature.deserialize(a_hex) const b_hex = b.serialize() expect(a_hex).toBe(b_hex) })