@@ -38,7 +38,11 @@ library ECDSA {
38
38
assembly {
39
39
result := 1
40
40
let m := mload (0x40 ) // Cache the free memory pointer.
41
- for {} 1 {} {
41
+ for {
42
+
43
+ } 1 {
44
+
45
+ } {
42
46
mstore (0x00 , hash)
43
47
mstore (0x40 , mload (add (signature, 0x20 ))) // `r`.
44
48
if eq (mload (signature), 64 ) {
@@ -55,17 +59,16 @@ library ECDSA {
55
59
result := 0
56
60
break
57
61
}
58
- result :=
59
- mload (
60
- staticcall (
61
- gas (), // Amount of gas left for the transaction.
62
- result, // Address of `ecrecover`.
63
- 0x00 , // Start of input.
64
- 0x80 , // Size of input.
65
- 0x01 , // Start of output.
66
- 0x20 // Size of output.
67
- )
62
+ result := mload (
63
+ staticcall (
64
+ gas (), // Amount of gas left for the transaction.
65
+ result, // Address of `ecrecover`.
66
+ 0x00 , // Start of input.
67
+ 0x80 , // Size of input.
68
+ 0x01 , // Start of output.
69
+ 0x20 // Size of output.
68
70
)
71
+ )
69
72
// `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
70
73
if iszero (returndatasize ()) {
71
74
mstore (0x00 , 0x8baa579f ) // `InvalidSignature()`.
@@ -83,7 +86,11 @@ library ECDSA {
83
86
result := 1
84
87
let m := mload (0x40 ) // Cache the free memory pointer.
85
88
mstore (0x00 , hash)
86
- for {} 1 {} {
89
+ for {
90
+
91
+ } 1 {
92
+
93
+ } {
87
94
if eq (signature.length , 64 ) {
88
95
let vs := calldataload (add (signature.offset, 0x20 ))
89
96
mstore (0x20 , add (shr (255 , vs), 27 )) // `v`.
@@ -99,17 +106,16 @@ library ECDSA {
99
106
result := 0
100
107
break
101
108
}
102
- result :=
103
- mload (
104
- staticcall (
105
- gas (), // Amount of gas left for the transaction.
106
- result, // Address of `ecrecover`.
107
- 0x00 , // Start of input.
108
- 0x80 , // Size of input.
109
- 0x01 , // Start of output.
110
- 0x20 // Size of output.
111
- )
109
+ result := mload (
110
+ staticcall (
111
+ gas (), // Amount of gas left for the transaction.
112
+ result, // Address of `ecrecover`.
113
+ 0x00 , // Start of input.
114
+ 0x80 , // Size of input.
115
+ 0x01 , // Start of output.
116
+ 0x20 // Size of output.
112
117
)
118
+ )
113
119
// `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
114
120
if iszero (returndatasize ()) {
115
121
mstore (0x00 , 0x8baa579f ) // `InvalidSignature()`.
@@ -130,17 +136,16 @@ library ECDSA {
130
136
mstore (0x20 , add (shr (255 , vs), 27 )) // `v`.
131
137
mstore (0x40 , r)
132
138
mstore (0x60 , shr (1 , shl (1 , vs))) // `s`.
133
- result :=
134
- mload (
135
- staticcall (
136
- gas (), // Amount of gas left for the transaction.
137
- 1 , // Address of `ecrecover`.
138
- 0x00 , // Start of input.
139
- 0x80 , // Size of input.
140
- 0x01 , // Start of output.
141
- 0x20 // Size of output.
142
- )
139
+ result := mload (
140
+ staticcall (
141
+ gas (), // Amount of gas left for the transaction.
142
+ 1 , // Address of `ecrecover`.
143
+ 0x00 , // Start of input.
144
+ 0x80 , // Size of input.
145
+ 0x01 , // Start of output.
146
+ 0x20 // Size of output.
143
147
)
148
+ )
144
149
// `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
145
150
if iszero (returndatasize ()) {
146
151
mstore (0x00 , 0x8baa579f ) // `InvalidSignature()`.
@@ -161,17 +166,16 @@ library ECDSA {
161
166
mstore (0x20 , and (v, 0xff ))
162
167
mstore (0x40 , r)
163
168
mstore (0x60 , s)
164
- result :=
165
- mload (
166
- staticcall (
167
- gas (), // Amount of gas left for the transaction.
168
- 1 , // Address of `ecrecover`.
169
- 0x00 , // Start of input.
170
- 0x80 , // Size of input.
171
- 0x01 , // Start of output.
172
- 0x20 // Size of output.
173
- )
169
+ result := mload (
170
+ staticcall (
171
+ gas (), // Amount of gas left for the transaction.
172
+ 1 , // Address of `ecrecover`.
173
+ 0x00 , // Start of input.
174
+ 0x80 , // Size of input.
175
+ 0x01 , // Start of output.
176
+ 0x20 // Size of output.
174
177
)
178
+ )
175
179
// `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
176
180
if iszero (returndatasize ()) {
177
181
mstore (0x00 , 0x8baa579f ) // `InvalidSignature()`.
@@ -198,7 +202,11 @@ library ECDSA {
198
202
assembly {
199
203
result := 1
200
204
let m := mload (0x40 ) // Cache the free memory pointer.
201
- for {} 1 {} {
205
+ for {
206
+
207
+ } 1 {
208
+
209
+ } {
202
210
mstore (0x00 , hash)
203
211
mstore (0x40 , mload (add (signature, 0x20 ))) // `r`.
204
212
if eq (mload (signature), 64 ) {
@@ -239,7 +247,11 @@ library ECDSA {
239
247
result := 1
240
248
let m := mload (0x40 ) // Cache the free memory pointer.
241
249
mstore (0x00 , hash)
242
- for {} 1 {} {
250
+ for {
251
+
252
+ } 1 {
253
+
254
+ } {
243
255
if eq (signature.length , 64 ) {
244
256
let vs := calldataload (add (signature.offset, 0x20 ))
245
257
mstore (0x20 , add (shr (255 , vs), 27 )) // `v`.
@@ -356,11 +368,17 @@ library ECDSA {
356
368
mstore (o, "\x19Ethereum Signed Message:\n " ) // 26 bytes, zero-right-padded.
357
369
mstore (0x00 , 0x00 )
358
370
// Convert the `s.length` to ASCII decimal representation: `base10(s.length)`.
359
- for { let temp := sLength } 1 {} {
371
+ for {
372
+ let temp := sLength
373
+ } 1 {
374
+
375
+ } {
360
376
o := sub (o, 1 )
361
377
mstore8 (o, add (48 , mod (temp, 10 )))
362
378
temp := div (temp, 10 )
363
- if iszero (temp) { break }
379
+ if iszero (temp) {
380
+ break
381
+ }
364
382
}
365
383
let n := sub (0x3a , o) // Header length: `26 + 32 - o`.
366
384
// Throw an out-of-offset error (consumes all gas) if the header exceeds 32 bytes.
0 commit comments