Elliptic curve
@webbuf/bch-schnorr
BCH Schnorr signatures using hash-free k256 WASM and existing SHA256 primitives.
Install
npm install @webbuf/bch-schnorrUsage
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
functionDeterministic 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
functionVerify BCH Schnorr (not BIP340). Malformed inputs return false.
bchSchnorrVerify(signature: FixedBuf<64>, digest: FixedBuf<32>, publicKey: PublicKeyBuf): boolean