Elliptic curve

@webbuf/bch-schnorr

BCH Schnorr signatures using hash-free k256 WASM and existing SHA256 primitives.

Install

npm install @webbuf/bch-schnorr

Usage

import { bchSchnorrSign, bchSchnorrVerify } from "@webbuf/bch-schnorr";
import { FixedBuf } from "@webbuf/fixedbuf";
import { publicKeyCreate } from "@webbuf/secp256k1";
// Public test key only. Never use it for funds.
const key = FixedBuf.fromHex(32, "01".padStart(64, "0"));
const digest = FixedBuf.alloc(32);
const signature = bchSchnorrSign(digest, key);
const valid = bchSchnorrVerify(signature, digest, publicKeyCreate(key));

API reference (2 exports)

Functions

bchSchnorrSign

function

Deterministic BCH Schnorr (not BIP340), over an already-hashed 32-byte message. Returns owned r||s, without a transaction sighash byte. No input is modified.

bchSchnorrSign(digest: FixedBuf<32>, privateKey: FixedBuf<32>): FixedBuf<64>

bchSchnorrVerify

function

Verify BCH Schnorr (not BIP340). Malformed inputs return false.

bchSchnorrVerify(signature: FixedBuf<64>, digest: FixedBuf<32>, publicKey: PublicKeyBuf): boolean