UNPKG

2.05 kBTypeScriptView Raw
1/// <reference types="node" />
2interface Network {
3 wif: number;
4 bip32: {
5 public: number;
6 private: number;
7 };
8 messagePrefix?: string;
9 bech32?: string;
10 pubKeyHash?: number;
11 scriptHash?: number;
12}
13export interface BIP32Interface {
14 chainCode: Buffer;
15 network: Network;
16 lowR: boolean;
17 depth: number;
18 index: number;
19 parentFingerprint: number;
20 publicKey: Buffer;
21 privateKey?: Buffer;
22 identifier: Buffer;
23 fingerprint: Buffer;
24 isNeutered(): boolean;
25 neutered(): BIP32Interface;
26 toBase58(): string;
27 toWIF(): string;
28 derive(index: number): BIP32Interface;
29 deriveHardened(index: number): BIP32Interface;
30 derivePath(path: string): BIP32Interface;
31 sign(hash: Buffer, lowR?: boolean): Buffer;
32 verify(hash: Buffer, signature: Buffer): boolean;
33 signSchnorr(hash: Buffer): Buffer;
34 verifySchnorr(hash: Buffer, signature: Buffer): boolean;
35}
36export interface BIP32API {
37 fromSeed(seed: Buffer, network?: Network): BIP32Interface;
38 fromBase58(inString: string, network?: Network): BIP32Interface;
39 fromPublicKey(publicKey: Buffer, chainCode: Buffer, network?: Network): BIP32Interface;
40 fromPrivateKey(privateKey: Buffer, chainCode: Buffer, network?: Network): BIP32Interface;
41}
42export interface TinySecp256k1Interface {
43 isPoint(p: Uint8Array): boolean;
44 isPrivate(d: Uint8Array): boolean;
45 pointFromScalar(d: Uint8Array, compressed?: boolean): Uint8Array | null;
46 pointAddScalar(p: Uint8Array, tweak: Uint8Array, compressed?: boolean): Uint8Array | null;
47 privateAdd(d: Uint8Array, tweak: Uint8Array): Uint8Array | null;
48 sign(h: Uint8Array, d: Uint8Array, e?: Uint8Array): Uint8Array;
49 signSchnorr?(h: Uint8Array, d: Uint8Array, e?: Uint8Array): Uint8Array;
50 verify(h: Uint8Array, Q: Uint8Array, signature: Uint8Array, strict?: boolean): boolean;
51 verifySchnorr?(h: Uint8Array, Q: Uint8Array, signature: Uint8Array): boolean;
52}
53export default function (ecc: TinySecp256k1Interface): BIP32API;
54export {};