forked from landabaso/bitcoinjs-message
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
90 lines (82 loc) · 2.44 KB
/
index.d.ts
File metadata and controls
90 lines (82 loc) · 2.44 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
interface SignatureOptions {
segwitType?: 'p2wpkh' | 'p2sh(p2wpkh)';
extraEntropy?: Uint8Array;
}
type RecoveryIdType = 0 | 1 | 2 | 3;
interface RecoverableSignature {
signature: Uint8Array;
recoveryId: RecoveryIdType;
}
export interface Signer {
// param hash: 32 byte Uint8Array containing the digest of the message
// param extraEntropy (optional): the 32 byte Uint8Array of the "extra data" part of RFC6979 nonces
// returns object
// attribute signature: 64 byte Uint8Array, first 32 R value, last 32 S value of ECDSA signature
// attribute recoveryId: Number (integer) from 0 to 3 (inclusive), also known as recid, used for pubkey recovery
signRecoverable(
hash: Uint8Array,
extraEntropy?: Uint8Array,
): RecoverableSignature;
}
export interface SignerAsync {
// Same as Signer, but return is wrapped in a Promise
signRecoverable(
hash: Uint8Array,
extraEntropy?: Uint8Array,
): Promise<RecoverableSignature>;
}
interface TinySecp256k1Interface {
signRecoverable(
h: Uint8Array,
d: Uint8Array,
e?: Uint8Array,
): RecoverableSignature;
recover(
h: Uint8Array,
signature: Uint8Array,
recoveryId: RecoveryIdType,
compressed?: boolean,
): Uint8Array | null;
}
export interface MessageAPI {
magicHash(
message: string | Uint8Array,
messagePrefix?: string | Uint8Array,
): Uint8Array;
// sign function is overloaded
sign(
message: string | Uint8Array,
privateKey: Uint8Array | Signer,
compressed?: boolean,
sigOptions?: SignatureOptions,
): Uint8Array;
sign(
message: string | Uint8Array,
privateKey: Uint8Array | Signer,
compressed?: boolean,
messagePrefix?: string | Uint8Array,
sigOptions?: SignatureOptions,
): Uint8Array;
// signAsync function is overloaded
signAsync(
message: string | Uint8Array,
privateKey: Uint8Array | SignerAsync | Signer,
compressed?: boolean,
sigOptions?: SignatureOptions,
): Promise<Uint8Array>;
signAsync(
message: string | Uint8Array,
privateKey: Uint8Array | SignerAsync | Signer,
compressed?: boolean,
messagePrefix?: string | Uint8Array,
sigOptions?: SignatureOptions,
): Promise<Uint8Array>;
verify(
message: string | Uint8Array,
address: string,
signature: string | Uint8Array,
messagePrefix?: string | Uint8Array,
checkSegwitAlways?: boolean,
): boolean;
}
export declare function MessageFactory(ecc: TinySecp256k1Interface): MessageAPI;