forked from bitcoinjs/bitcoinjs-message
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
61 lines (55 loc) · 1.79 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
interface SignatureOptions {
segwitType?: 'p2wpkh' | 'p2sh(p2wpkh)';
extraEntropy?: Buffer;
}
export interface Signer {
// param hash: 32 byte Buffer containing the digest of the message
// param extraEntropy (optional): the 32 byte Buffer of the "extra data" part of RFC6979 nonces
// returns object
// attribute signature: 64 byte Buffer, first 32 R value, last 32 S value of ECDSA signature
// attribute recovery: Number (integer) from 0 to 3 (inclusive), also known as recid, used for pubkey recovery
sign(hash: Buffer, extraEntropy?: Buffer): { signature: Buffer; recovery: number; };
}
export interface SignerAsync {
// Same as Signer, but return is wrapped in a Promise
sign(hash: Buffer, extraEntropy?: Buffer): Promise<{ signature: Buffer; recovery: number; }>;
}
export function magicHash(
message: string | Buffer,
messagePrefix?: string
): Buffer;
// sign function is overloaded
export function sign(
message: string | Buffer,
privateKey: Buffer | Signer,
compressed?: boolean,
sigOptions?: SignatureOptions
): Buffer;
export function sign(
message: string | Buffer,
privateKey: Buffer | Signer,
compressed?: boolean,
messagePrefix?: string,
sigOptions?: SignatureOptions
): Buffer;
// signAsync function is overloaded
export function signAsync(
message: string | Buffer,
privateKey: Buffer | SignerAsync | Signer,
compressed?: boolean,
sigOptions?: SignatureOptions
): Promise<Buffer>;
export function signAsync(
message: string | Buffer,
privateKey: Buffer | SignerAsync | Signer,
compressed?: boolean,
messagePrefix?: string,
sigOptions?: SignatureOptions
): Promise<Buffer>;
export function verify(
message: string | Buffer,
address: string,
signature: string | Buffer,
messagePrefix?: string,
checkSegwitAlways?: boolean
): boolean;