-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathsignature.d.ts
More file actions
190 lines (190 loc) · 5.18 KB
/
signature.d.ts
File metadata and controls
190 lines (190 loc) · 5.18 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
import type { BigNumberish, BytesLike } from "../utils/index.js";
declare const inspect: unique symbol;
/**
* A SignatureLike
*
* @_docloc: api/crypto:Signing
*/
export type SignatureLike = Signature | string | {
r: string;
s: string;
v: BigNumberish;
yParity?: 0 | 1;
yParityAndS?: string;
} | {
r: string;
yParityAndS: string;
yParity?: 0 | 1;
s?: string;
v?: number;
} | {
r: string;
s: string;
yParity: 0 | 1;
v?: BigNumberish;
yParityAndS?: string;
};
/**
* A Signature @TODO
*
*
* @_docloc: api/crypto:Signing
*/
export declare class Signature {
#private;
/**
* The ``r`` value for a signature.
*
* This represents the ``x`` coordinate of a "reference" or
* challenge point, from which the ``y`` can be computed.
*/
get r(): string;
set r(value: BytesLike);
/**
* The ``s`` value for a signature.
*/
get s(): string;
set s(_value: BytesLike);
/**
* Return the s value, unchecked for EIP-2 compliance.
*
* This should generally not be used and is for situations where
* a non-canonical S value might be relevant, such as Frontier blocks
* that were mined prior to EIP-2 or invalid Authorization List
* signatures.
*/
get _s(): string;
/**
* Returns true if the Signature is valid for [[link-eip-2]] signatures.
*/
isValid(): boolean;
/**
* The ``v`` value for a signature.
*
* Since a given ``x`` value for ``r`` has two possible values for
* its correspondin ``y``, the ``v`` indicates which of the two ``y``
* values to use.
*
* It is normalized to the values ``27`` or ``28`` for legacy
* purposes.
*/
get v(): 27 | 28;
set v(value: BigNumberish);
/**
* The EIP-155 ``v`` for legacy transactions. For non-legacy
* transactions, this value is ``null``.
*/
get networkV(): null | bigint;
/**
* The chain ID for EIP-155 legacy transactions. For non-legacy
* transactions, this value is ``null``.
*/
get legacyChainId(): null | bigint;
/**
* The ``yParity`` for the signature.
*
* See ``v`` for more details on how this value is used.
*/
get yParity(): 0 | 1;
/**
* The [[link-eip-2098]] compact representation of the ``yParity``
* and ``s`` compacted into a single ``bytes32``.
*/
get yParityAndS(): string;
/**
* The [[link-eip-2098]] compact representation.
*/
get compactSerialized(): string;
/**
* The serialized representation.
*/
get serialized(): string;
/**
* @private
*/
constructor(guard: any, r: string, s: string, v: 27 | 28);
/**
* Returns the canonical signature.
*
* This is only necessary when dealing with legacy transaction which
* did not enforce canonical S values (i.e. [[link-eip-2]]. Most
* developers should never require this.
*/
getCanonical(): Signature;
/**
* Returns the bound signature, binding `v`
*
* Bound signatures are valid for ecrecover but may be invalid for transactions.
* They are used for ERC-XXXX signature compression.
*/
bind(v?: 27 | 28): Signature;
/**
* Returns a new identical [[Signature]].
*/
clone(): Signature;
/**
* Returns a representation that is compatible with ``JSON.stringify``.
*/
toJSON(): any;
[inspect](): string;
toString(): string;
/**
* Compute the chain ID from the ``v`` in a legacy EIP-155 transactions.
*
* @example:
* Signature.getChainId(45)
* //_result:
*
* Signature.getChainId(46)
* //_result:
*/
static getChainId(v: BigNumberish): bigint;
/**
* Compute the ``v`` for a chain ID for a legacy EIP-155 transactions.
*
* Legacy transactions which use [[link-eip-155]] hijack the ``v``
* property to include the chain ID.
*
* @example:
* Signature.getChainIdV(5, 27)
* //_result:
*
* Signature.getChainIdV(5, 28)
* //_result:
*
*/
static getChainIdV(chainId: BigNumberish, v: 27 | 28): bigint;
/**
* Compute the normalized legacy transaction ``v`` from a ``yParirty``,
* a legacy transaction ``v`` or a legacy [[link-eip-155]] transaction.
*
* @example:
* // The values 0 and 1 imply v is actually yParity
* Signature.getNormalizedV(0)
* //_result:
*
* // Legacy non-EIP-1559 transaction (i.e. 27 or 28)
* Signature.getNormalizedV(27)
* //_result:
*
* // Legacy EIP-155 transaction (i.e. >= 35)
* Signature.getNormalizedV(46)
* //_result:
*
* // Invalid values throw
* Signature.getNormalizedV(5)
* //_error:
*/
static getNormalizedV(v: BigNumberish): 27 | 28;
/**
* Creates a new [[Signature]].
*
* If no %%sig%% is provided, a new [[Signature]] is created
* with default values.
*
* If %%sig%% is a string, it is parsed.
*/
static from(sig?: SignatureLike): Signature;
}
export {};
//# sourceMappingURL=signature.d.ts.map