UNPKG

libnexa-ts

Version:

A pure and powerful Nexa SDK library.

39 lines 1.89 kB
import { IPrivateKey, IPublicKey, ISignature } from '../common/interfaces'; import { EndianType } from '../common/types'; import { default as BN } from './bn.extension'; import { default as DigitalSignature } from './digital-signature'; export default class Schnorr extends DigitalSignature { sigError(): boolean | string; /** * RFC6979 deterministic nonce generation used from https://reviews.bitcoinabc.org/D2501 * * @param privkeybuf * @param msgbuf * @return BN nonce */ nonceFunctionRFC6979(privkeybuf: Uint8Array, msgbuf: Uint8Array): BN; /** * @remarks * Important references for schnorr implementation {@link https://spec.nexa.org/forks/2019-05-15-schnorr/} * * @param d the private key * @param e the message to be signed */ protected _findSignature(d: BN, e: BN): Partial<ISignature>; /** * Function written to ensure s or r parts of signature is at least 32 bytes, when converting * from a BN to type Uint8Array. * The BN type naturally cuts off leading zeros, e.g. * <BN: 4f92d8094f710bc11b93935ac157730dda26c5c2a856650dbd8ebcd730d2d4> 31 bytes * Buffer <00 4f 92 d8 09 4f 71 0b c1 1b 93 93 5a c1 57 73 0d da 26 c5 c2 a8 56 65 0d bd 8e bc d7 30 d2 d4> 32 bytes * Both types are equal, however Schnorr signatures must be a minimum of 64 bytes. * In a previous implementation of this schnorr module, was resulting in 63 byte signatures. * (Although it would have been verified, it's proper to ensure the min requirement) * * @param bn the r or s signature part */ private static getProperSizeBuffer; static sign(hashbuf: Uint8Array, privkey: IPrivateKey, endian: EndianType): ISignature; static verify(hashbuf: Uint8Array, sig: ISignature, pubkey: IPublicKey, endian: EndianType): boolean; } //# sourceMappingURL=schnorr.d.ts.map