UNPKG

dedoopair

Version:

Blockchain Agnostic ECPair library for Bitcoin-like cryptocurrencies

58 lines (57 loc) 2.21 kB
/// <reference types="node" /> /// <reference types="node" /> import { Network } from 'dedoo-coinjs-lib'; interface ECPairOptions { compressed?: boolean; network?: Network; rng?(arg0: number): Buffer; } export interface Signer { publicKey: Buffer; network?: any; sign(hash: Buffer, lowR?: boolean): Buffer; getPublicKey?(): Buffer; } export interface SignerAsync { publicKey: Buffer; network?: any; sign(hash: Buffer, lowR?: boolean): Promise<Buffer>; getPublicKey?(): Buffer; } export interface ECPairInterface extends Signer { compressed: boolean; network: Network; lowR: boolean; privateKey?: Buffer; toWIF(): string; tweak(t: Buffer): ECPairInterface; verify(hash: Buffer, signature: Buffer): boolean; verifySchnorr(hash: Buffer, signature: Buffer): boolean; signSchnorr(hash: Buffer): Buffer; } export interface ECPairAPI { isPoint(maybePoint: any): boolean; fromPrivateKey(buffer: Buffer, options?: ECPairOptions): ECPairInterface; fromPublicKey(buffer: Buffer, options?: ECPairOptions): ECPairInterface; fromWIF(wifString: string, network?: Network | Network[]): ECPairInterface; makeRandom(options?: ECPairOptions): ECPairInterface; } export interface TinySecp256k1Interface { isPoint(p: Uint8Array): boolean; pointCompress(p: Uint8Array, compressed?: boolean): Uint8Array; isPrivate(d: Uint8Array): boolean; pointFromScalar(d: Uint8Array, compressed?: boolean): Uint8Array | null; xOnlyPointAddTweak(p: Uint8Array, tweak: Uint8Array): XOnlyPointAddTweakResult | null; privateAdd(d: Uint8Array, tweak: Uint8Array): Uint8Array | null; privateNegate(d: Uint8Array): Uint8Array; sign(h: Uint8Array, d: Uint8Array, e?: Uint8Array): Uint8Array; signSchnorr?(h: Uint8Array, d: Uint8Array, e?: Uint8Array): Uint8Array; verify(h: Uint8Array, Q: Uint8Array, signature: Uint8Array, strict?: boolean): boolean; verifySchnorr?(h: Uint8Array, Q: Uint8Array, signature: Uint8Array): boolean; } interface XOnlyPointAddTweakResult { parity: 1 | 0; xOnlyPubkey: Uint8Array; } export declare function ECPairFactory(ecc: TinySecp256k1Interface): ECPairAPI; export {};