libnexa-ts
Version:
A pure and powerful Nexa SDK library.
51 lines • 1.84 kB
TypeScript
import { ISignature } from '../common/interfaces';
import { default as BN } from './bn.extension';
export default class Signature implements ISignature {
r: BN;
s: BN;
i?: number;
compressed?: boolean;
constructor(params: Partial<ISignature>);
toBuffer(isSchnorr?: boolean): Uint8Array;
toTxFormat(sighashBuf?: Uint8Array): Uint8Array;
toString(isSchnorr?: boolean): string;
/**
* Schnorr signatures are 64 bytes: r [len] 32 || s [len] 32.
*
* There can be a few more bytes that is the sighashtype. It needs to be trimmed before calling this.
*/
static fromBuffer(buf: Uint8Array, strict?: boolean): Signature;
/**
* The format used in a tx.
* schnorr is 64 bytes, the rest are sighashtype bytes
*
* @param buf
*/
static fromTxFormat(buf: Uint8Array): Signature;
/**
* This assumes the str is a raw signature and does not have sighashtype.
* Use {@link Signature.fromTxString} when decoding a tx
*
* @param str the signature hex string
* @see fromTxString
*/
static fromString(str: string): Signature;
/**
* This assumes the str might have sighashtype bytes and will trim it if needed.
* Use this when decoding a tx signature string
*
* @param str the tx signature hex string
*/
static fromTxString(str: string): Signature;
private static parseSchnorrEncodedSig;
/**
* For ECDSA. In order to mimic the non-strict DER encoding of OpenSSL, set strict = false.
*/
static parseDER(buf: Uint8Array, strict?: boolean): Record<string, unknown>;
/**
* ECDSA format. used for sign messages
*/
toCompact(i?: number, compressed?: boolean): Uint8Array;
static fromCompact(buf: Uint8Array): Signature;
}
//# sourceMappingURL=signature.d.ts.map