@@ -59,7 +59,11 @@ contract SemaphoreVerifier {
59
59
mstore (add (mIn, 32 ), y)
60
60
mstore (add (mIn, 64 ), s)
61
61
62
- success := staticcall (gas (), 7 , mIn, 96 , mIn, 64 )
62
+ // ref: https://www.evm.codes/precompiled 0x07 ecMul
63
+ // If inputs are valid, fixed gas cost 6000 is consumed.
64
+ // If inputs are invalid, all gas is consumed but is limited to 6000 in this case.
65
+ // `iszero(success)` will be true afterwards.
66
+ success := staticcall (6000 , 7 , mIn, 96 , mIn, 64 )
63
67
64
68
if iszero (success) {
65
69
mstore (0 , 0 )
@@ -69,7 +73,11 @@ contract SemaphoreVerifier {
69
73
mstore (add (mIn, 64 ), mload (pR))
70
74
mstore (add (mIn, 96 ), mload (add (pR, 32 )))
71
75
72
- success := staticcall (gas (), 6 , mIn, 128 , pR, 64 )
76
+ // ref: https://www.evm.codes/precompiled 0x06 ecAdd
77
+ // If inputs are valid, fixed gas cost 150 is consumed.
78
+ // If inputs are invalid, all gas is consumed but is limited to 150 in this case.
79
+ // `iszero(success)` will be true afterwards.
80
+ success := staticcall (150 , 6 , mIn, 128 , pR, 64 )
73
81
74
82
if iszero (success) {
75
83
mstore (0 , 0 )
@@ -149,7 +157,9 @@ contract SemaphoreVerifier {
149
157
mstore (add (_pPairing, 704 ), mload (add (vkPoints, 64 )))
150
158
mstore (add (_pPairing, 736 ), mload (add (vkPoints, 96 )))
151
159
152
- let success := staticcall (gas (), 8 , _pPairing, 768 , _pPairing, 0x20 )
160
+ // ref: https://www.evm.codes/precompiled 0x08 ecPairing
161
+ // Given the input size 768 bytes, gas cost is computed from the above web page.
162
+ let success := staticcall (181000 , 8 , _pPairing, 768 , _pPairing, 0x20 )
153
163
154
164
isOk := and (success, mload (_pPairing))
155
165
}
0 commit comments