zkjson 0.1.30 → 0.1.32
Sign up to get free protection for your applications and to get access to all the features.
- package/circomlibjs.js +169 -127
- package/contracts/OPRollup.sol +33 -0
- package/contracts/verifiers/verifier_db.sol +261 -0
- package/contracts/verifiers/verifier_ipfs.sol +464 -0
- package/contracts/verifiers/verifier_json.sol +247 -0
- package/contracts/verifiers/verifier_rollup.sol +240 -0
- package/package.json +1 -1
@@ -0,0 +1,247 @@
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0
|
2
|
+
/*
|
3
|
+
Copyright 2021 0KIMS association.
|
4
|
+
|
5
|
+
This file is generated with [snarkJS](https://github.com/iden3/snarkjs).
|
6
|
+
|
7
|
+
snarkJS is a free software: you can redistribute it and/or modify it
|
8
|
+
under the terms of the GNU General Public License as published by
|
9
|
+
the Free Software Foundation, either version 3 of the License, or
|
10
|
+
(at your option) any later version.
|
11
|
+
|
12
|
+
snarkJS is distributed in the hope that it will be useful, but WITHOUT
|
13
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
14
|
+
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
15
|
+
License for more details.
|
16
|
+
|
17
|
+
You should have received a copy of the GNU General Public License
|
18
|
+
along with snarkJS. If not, see <https://www.gnu.org/licenses/>.
|
19
|
+
*/
|
20
|
+
|
21
|
+
pragma solidity >=0.7.0 <0.9.0;
|
22
|
+
|
23
|
+
contract Groth16VerifierJSON {
|
24
|
+
// Scalar field size
|
25
|
+
uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
|
26
|
+
// Base field size
|
27
|
+
uint256 constant q = 21888242871839275222246405745257275088696311157297823662689037894645226208583;
|
28
|
+
|
29
|
+
// Verification Key data
|
30
|
+
uint256 constant alphax = 20906723375066628996538723964948705883807515490851236717549543933647949219571;
|
31
|
+
uint256 constant alphay = 16603277405602064515576336929405274585704793668006611444340674010517699111175;
|
32
|
+
uint256 constant betax1 = 15094144295718056060696456976805274960280819890173699163580614297205641683890;
|
33
|
+
uint256 constant betax2 = 2598197794696234583089212408001367512889853689394097760090270035862816362448;
|
34
|
+
uint256 constant betay1 = 13019389669452630605176375079598340867413494236340581417103700533129069013294;
|
35
|
+
uint256 constant betay2 = 17948608722772603517072567060031950359342932415845723852078363636578090462964;
|
36
|
+
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
|
37
|
+
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
|
38
|
+
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
|
39
|
+
uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
|
40
|
+
uint256 constant deltax1 = 16323886806377948767625289345386923912488425685292264502851407533751890364893;
|
41
|
+
uint256 constant deltax2 = 15728036135898260810892479278030679906213338463446298332250898095140196532350;
|
42
|
+
uint256 constant deltay1 = 7311361608150524708643711937539709432213365833416427921151717898214981893794;
|
43
|
+
uint256 constant deltay2 = 5360237348765695204487062346058482342794521371770543578645384390456849442785;
|
44
|
+
|
45
|
+
|
46
|
+
uint256 constant IC0x = 11086791052709537593958527982551466373543557342479473456486918346706557110272;
|
47
|
+
uint256 constant IC0y = 20506728735254563637401848289764804706365355653222631223947955738675551382105;
|
48
|
+
|
49
|
+
uint256 constant IC1x = 3395672018504856885331557568801382430991065622809977080049087938633695466505;
|
50
|
+
uint256 constant IC1y = 16008515660025396265007279223380117478922266924915694760300639683710667540804;
|
51
|
+
|
52
|
+
uint256 constant IC2x = 21765086794018723313508040688349754864858333265049520578918793850946099000275;
|
53
|
+
uint256 constant IC2y = 697811386339903182398036069234656900767187661360875928460814734795207770242;
|
54
|
+
|
55
|
+
uint256 constant IC3x = 19890134840469468860269808836413274874961102551504281644286795822862783578836;
|
56
|
+
uint256 constant IC3y = 10501563686653873312925081348712045837799559277882754134863746661191456585317;
|
57
|
+
|
58
|
+
uint256 constant IC4x = 3369539760301949842926296294765952701286437018123521538030683232199073077793;
|
59
|
+
uint256 constant IC4y = 17029305206701174018920590641604979023986372135961726666915339433517762654894;
|
60
|
+
|
61
|
+
uint256 constant IC5x = 16249858468384073197585049724261300836640451596079332252974671216468387477562;
|
62
|
+
uint256 constant IC5y = 15430518669979717234332245816406403303816581724709051740811390921375347110404;
|
63
|
+
|
64
|
+
uint256 constant IC6x = 15005432332128787752647304265070458721246744260154464921566645180007742802279;
|
65
|
+
uint256 constant IC6y = 12228853074973908182958795852882093001137862796451033278357411806506635324421;
|
66
|
+
|
67
|
+
uint256 constant IC7x = 8279149102391716348028737479566814742618645832848275208331642895717107868296;
|
68
|
+
uint256 constant IC7y = 9028245630419080537816021983399031211599915437683007034212436702559232452386;
|
69
|
+
|
70
|
+
uint256 constant IC8x = 9920315178591554201395269399878868095438996004668427910727172420497691574268;
|
71
|
+
uint256 constant IC8y = 13977539708344722958417991918934496531835259337681036150638988886470196226252;
|
72
|
+
|
73
|
+
uint256 constant IC9x = 64865284880675837338119066159408029670824664912895548295809933993597129855;
|
74
|
+
uint256 constant IC9y = 16596614162936398597796948615700133880646516840294055167278997135786201638865;
|
75
|
+
|
76
|
+
uint256 constant IC10x = 20041216278333661355857000399562164892538427870735609885548447419114215265900;
|
77
|
+
uint256 constant IC10y = 7188425125877597681508434156838946918685965411196380330181753494345911319474;
|
78
|
+
|
79
|
+
uint256 constant IC11x = 10344667596317540812042141319424780533548696928275174590606414302423871416439;
|
80
|
+
uint256 constant IC11y = 15177912543756596934916481207669485500307163540835148656062032711878901603531;
|
81
|
+
|
82
|
+
uint256 constant IC12x = 3003572233500184455318954446784006239696026573012811847295348627074111281539;
|
83
|
+
uint256 constant IC12y = 6485361686957307324235352983357156310358934769793375149333110905137006337248;
|
84
|
+
|
85
|
+
|
86
|
+
// Memory data
|
87
|
+
uint16 constant pVk = 0;
|
88
|
+
uint16 constant pPairing = 128;
|
89
|
+
|
90
|
+
uint16 constant pLastMem = 896;
|
91
|
+
|
92
|
+
function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[12] calldata _pubSignals) public view returns (bool) {
|
93
|
+
assembly {
|
94
|
+
function checkField(v) {
|
95
|
+
if iszero(lt(v, q)) {
|
96
|
+
mstore(0, 0)
|
97
|
+
return(0, 0x20)
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
// G1 function to multiply a G1 value(x,y) to value in an address
|
102
|
+
function g1_mulAccC(pR, x, y, s) {
|
103
|
+
let success
|
104
|
+
let mIn := mload(0x40)
|
105
|
+
mstore(mIn, x)
|
106
|
+
mstore(add(mIn, 32), y)
|
107
|
+
mstore(add(mIn, 64), s)
|
108
|
+
|
109
|
+
success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
|
110
|
+
|
111
|
+
if iszero(success) {
|
112
|
+
mstore(0, 0)
|
113
|
+
return(0, 0x20)
|
114
|
+
}
|
115
|
+
|
116
|
+
mstore(add(mIn, 64), mload(pR))
|
117
|
+
mstore(add(mIn, 96), mload(add(pR, 32)))
|
118
|
+
|
119
|
+
success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
|
120
|
+
|
121
|
+
if iszero(success) {
|
122
|
+
mstore(0, 0)
|
123
|
+
return(0, 0x20)
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk {
|
128
|
+
let _pPairing := add(pMem, pPairing)
|
129
|
+
let _pVk := add(pMem, pVk)
|
130
|
+
|
131
|
+
mstore(_pVk, IC0x)
|
132
|
+
mstore(add(_pVk, 32), IC0y)
|
133
|
+
|
134
|
+
// Compute the linear combination vk_x
|
135
|
+
|
136
|
+
g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0)))
|
137
|
+
|
138
|
+
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
|
139
|
+
|
140
|
+
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
|
141
|
+
|
142
|
+
g1_mulAccC(_pVk, IC4x, IC4y, calldataload(add(pubSignals, 96)))
|
143
|
+
|
144
|
+
g1_mulAccC(_pVk, IC5x, IC5y, calldataload(add(pubSignals, 128)))
|
145
|
+
|
146
|
+
g1_mulAccC(_pVk, IC6x, IC6y, calldataload(add(pubSignals, 160)))
|
147
|
+
|
148
|
+
g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192)))
|
149
|
+
|
150
|
+
g1_mulAccC(_pVk, IC8x, IC8y, calldataload(add(pubSignals, 224)))
|
151
|
+
|
152
|
+
g1_mulAccC(_pVk, IC9x, IC9y, calldataload(add(pubSignals, 256)))
|
153
|
+
|
154
|
+
g1_mulAccC(_pVk, IC10x, IC10y, calldataload(add(pubSignals, 288)))
|
155
|
+
|
156
|
+
g1_mulAccC(_pVk, IC11x, IC11y, calldataload(add(pubSignals, 320)))
|
157
|
+
|
158
|
+
g1_mulAccC(_pVk, IC12x, IC12y, calldataload(add(pubSignals, 352)))
|
159
|
+
|
160
|
+
|
161
|
+
// -A
|
162
|
+
mstore(_pPairing, calldataload(pA))
|
163
|
+
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
|
164
|
+
|
165
|
+
// B
|
166
|
+
mstore(add(_pPairing, 64), calldataload(pB))
|
167
|
+
mstore(add(_pPairing, 96), calldataload(add(pB, 32)))
|
168
|
+
mstore(add(_pPairing, 128), calldataload(add(pB, 64)))
|
169
|
+
mstore(add(_pPairing, 160), calldataload(add(pB, 96)))
|
170
|
+
|
171
|
+
// alpha1
|
172
|
+
mstore(add(_pPairing, 192), alphax)
|
173
|
+
mstore(add(_pPairing, 224), alphay)
|
174
|
+
|
175
|
+
// beta2
|
176
|
+
mstore(add(_pPairing, 256), betax1)
|
177
|
+
mstore(add(_pPairing, 288), betax2)
|
178
|
+
mstore(add(_pPairing, 320), betay1)
|
179
|
+
mstore(add(_pPairing, 352), betay2)
|
180
|
+
|
181
|
+
// vk_x
|
182
|
+
mstore(add(_pPairing, 384), mload(add(pMem, pVk)))
|
183
|
+
mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32))))
|
184
|
+
|
185
|
+
|
186
|
+
// gamma2
|
187
|
+
mstore(add(_pPairing, 448), gammax1)
|
188
|
+
mstore(add(_pPairing, 480), gammax2)
|
189
|
+
mstore(add(_pPairing, 512), gammay1)
|
190
|
+
mstore(add(_pPairing, 544), gammay2)
|
191
|
+
|
192
|
+
// C
|
193
|
+
mstore(add(_pPairing, 576), calldataload(pC))
|
194
|
+
mstore(add(_pPairing, 608), calldataload(add(pC, 32)))
|
195
|
+
|
196
|
+
// delta2
|
197
|
+
mstore(add(_pPairing, 640), deltax1)
|
198
|
+
mstore(add(_pPairing, 672), deltax2)
|
199
|
+
mstore(add(_pPairing, 704), deltay1)
|
200
|
+
mstore(add(_pPairing, 736), deltay2)
|
201
|
+
|
202
|
+
|
203
|
+
let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
|
204
|
+
|
205
|
+
isOk := and(success, mload(_pPairing))
|
206
|
+
}
|
207
|
+
|
208
|
+
let pMem := mload(0x40)
|
209
|
+
mstore(0x40, add(pMem, pLastMem))
|
210
|
+
|
211
|
+
// Validate that all evaluations ∈ F
|
212
|
+
|
213
|
+
checkField(calldataload(add(_pubSignals, 0)))
|
214
|
+
|
215
|
+
checkField(calldataload(add(_pubSignals, 32)))
|
216
|
+
|
217
|
+
checkField(calldataload(add(_pubSignals, 64)))
|
218
|
+
|
219
|
+
checkField(calldataload(add(_pubSignals, 96)))
|
220
|
+
|
221
|
+
checkField(calldataload(add(_pubSignals, 128)))
|
222
|
+
|
223
|
+
checkField(calldataload(add(_pubSignals, 160)))
|
224
|
+
|
225
|
+
checkField(calldataload(add(_pubSignals, 192)))
|
226
|
+
|
227
|
+
checkField(calldataload(add(_pubSignals, 224)))
|
228
|
+
|
229
|
+
checkField(calldataload(add(_pubSignals, 256)))
|
230
|
+
|
231
|
+
checkField(calldataload(add(_pubSignals, 288)))
|
232
|
+
|
233
|
+
checkField(calldataload(add(_pubSignals, 320)))
|
234
|
+
|
235
|
+
checkField(calldataload(add(_pubSignals, 352)))
|
236
|
+
|
237
|
+
checkField(calldataload(add(_pubSignals, 384)))
|
238
|
+
|
239
|
+
|
240
|
+
// Validate all evaluations
|
241
|
+
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
|
242
|
+
|
243
|
+
mstore(0, isValid)
|
244
|
+
return(0, 0x20)
|
245
|
+
}
|
246
|
+
}
|
247
|
+
}
|
@@ -0,0 +1,240 @@
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0
|
2
|
+
/*
|
3
|
+
Copyright 2021 0KIMS association.
|
4
|
+
|
5
|
+
This file is generated with [snarkJS](https://github.com/iden3/snarkjs).
|
6
|
+
|
7
|
+
snarkJS is a free software: you can redistribute it and/or modify it
|
8
|
+
under the terms of the GNU General Public License as published by
|
9
|
+
the Free Software Foundation, either version 3 of the License, or
|
10
|
+
(at your option) any later version.
|
11
|
+
|
12
|
+
snarkJS is distributed in the hope that it will be useful, but WITHOUT
|
13
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
14
|
+
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
15
|
+
License for more details.
|
16
|
+
|
17
|
+
You should have received a copy of the GNU General Public License
|
18
|
+
along with snarkJS. If not, see <https://www.gnu.org/licenses/>.
|
19
|
+
*/
|
20
|
+
|
21
|
+
pragma solidity >=0.7.0 <0.9.0;
|
22
|
+
|
23
|
+
contract Groth16VerifierRU {
|
24
|
+
// Scalar field size
|
25
|
+
uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
|
26
|
+
// Base field size
|
27
|
+
uint256 constant q = 21888242871839275222246405745257275088696311157297823662689037894645226208583;
|
28
|
+
|
29
|
+
// Verification Key data
|
30
|
+
uint256 constant alphax = 8154397773694967106321908543225581308345926075547707849461770589063806208933;
|
31
|
+
uint256 constant alphay = 5677108055266898448889486339855982693826760854574703967712162419621387623014;
|
32
|
+
uint256 constant betax1 = 4355293952982460708458173032048895255835173115891032808050720056003898803424;
|
33
|
+
uint256 constant betax2 = 3059800330157143526908077176335177789758447764497844662322128804304930412762;
|
34
|
+
uint256 constant betay1 = 12948155637479005941322226125984465377528965309571693953410360452319923301251;
|
35
|
+
uint256 constant betay2 = 7332222563511878888805485279601765944630172818413249156252409812683246711891;
|
36
|
+
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
|
37
|
+
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
|
38
|
+
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
|
39
|
+
uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
|
40
|
+
uint256 constant deltax1 = 20503591479484091524389745903571071797103515451455738548515763475839920684921;
|
41
|
+
uint256 constant deltax2 = 5617943403828393228867947181181000280381763965560908736009901041763172427158;
|
42
|
+
uint256 constant deltay1 = 19083313989582849416852727426203922087129577621288485271208858162180563989517;
|
43
|
+
uint256 constant deltay2 = 6862756714407978275897080062526754044127957156216819881004695153747745594448;
|
44
|
+
|
45
|
+
|
46
|
+
uint256 constant IC0x = 8117166905692109919104291343856029475477412767491303376211389191152967038468;
|
47
|
+
uint256 constant IC0y = 9786515749803639719852807382408592347129424775311166090035686108630492765324;
|
48
|
+
|
49
|
+
uint256 constant IC1x = 8372619712685736857836778212277410061184000966061820660353663736436010324900;
|
50
|
+
uint256 constant IC1y = 7067497483771029122224543049910217766313555809959258482125432607420578209549;
|
51
|
+
|
52
|
+
uint256 constant IC2x = 8664544978528071254218294973797032588678014503773496766308416357733046318778;
|
53
|
+
uint256 constant IC2y = 1718370739886043626655047048989167081845643514431816517183086335106787323814;
|
54
|
+
|
55
|
+
uint256 constant IC3x = 17751478333748864683647456466294726036073972233143791990284780060329145813120;
|
56
|
+
uint256 constant IC3y = 5332438974111244723611637766367681701415489964863909660487320379077476391752;
|
57
|
+
|
58
|
+
uint256 constant IC4x = 20742828080385750796683930560189396553036781354782278562302384256732853843949;
|
59
|
+
uint256 constant IC4y = 1351673933396889997409523595926983213620423546050525776383348532660582633773;
|
60
|
+
|
61
|
+
uint256 constant IC5x = 20503268205499473416904271262498573431374552398139117269682363052068963140978;
|
62
|
+
uint256 constant IC5y = 3732804412299701993142127591762498360367649767364421523113109866299226710165;
|
63
|
+
|
64
|
+
uint256 constant IC6x = 14257995503266038917376264725392135727319727614567664291464265707947560137941;
|
65
|
+
uint256 constant IC6y = 341674734661014039525000101720981104421961371042562178520683297866596707154;
|
66
|
+
|
67
|
+
uint256 constant IC7x = 8193832556543527639708689676411352413933876589415237015016698770441031255042;
|
68
|
+
uint256 constant IC7y = 6594427869611603078697503063082014095062802376771554910392397589449346189644;
|
69
|
+
|
70
|
+
uint256 constant IC8x = 13583345943944676979948187443700187050998549308300528606491967244177176520006;
|
71
|
+
uint256 constant IC8y = 4938411793249197289917720689106756285526796809363092891408044710943884674802;
|
72
|
+
|
73
|
+
uint256 constant IC9x = 11332284497411134754454830299053795514601435700763578724160974435166700044531;
|
74
|
+
uint256 constant IC9y = 13019000604073974366403109311897527900603263821666939992822627393063021671404;
|
75
|
+
|
76
|
+
uint256 constant IC10x = 14399226292391120536283418546213611923264868223599916657548457588778188745914;
|
77
|
+
uint256 constant IC10y = 15721807309515116598525148493431362514780681023570830598111469229105621080436;
|
78
|
+
|
79
|
+
uint256 constant IC11x = 9762413796519510440691741324561546062505760014187240868624893625208356342750;
|
80
|
+
uint256 constant IC11y = 16246137136591544636923946475468706707718504791810616178029498386514365251482;
|
81
|
+
|
82
|
+
|
83
|
+
// Memory data
|
84
|
+
uint16 constant pVk = 0;
|
85
|
+
uint16 constant pPairing = 128;
|
86
|
+
|
87
|
+
uint16 constant pLastMem = 896;
|
88
|
+
|
89
|
+
function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[11] calldata _pubSignals) public view returns (bool) {
|
90
|
+
assembly {
|
91
|
+
function checkField(v) {
|
92
|
+
if iszero(lt(v, q)) {
|
93
|
+
mstore(0, 0)
|
94
|
+
return(0, 0x20)
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
// G1 function to multiply a G1 value(x,y) to value in an address
|
99
|
+
function g1_mulAccC(pR, x, y, s) {
|
100
|
+
let success
|
101
|
+
let mIn := mload(0x40)
|
102
|
+
mstore(mIn, x)
|
103
|
+
mstore(add(mIn, 32), y)
|
104
|
+
mstore(add(mIn, 64), s)
|
105
|
+
|
106
|
+
success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
|
107
|
+
|
108
|
+
if iszero(success) {
|
109
|
+
mstore(0, 0)
|
110
|
+
return(0, 0x20)
|
111
|
+
}
|
112
|
+
|
113
|
+
mstore(add(mIn, 64), mload(pR))
|
114
|
+
mstore(add(mIn, 96), mload(add(pR, 32)))
|
115
|
+
|
116
|
+
success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
|
117
|
+
|
118
|
+
if iszero(success) {
|
119
|
+
mstore(0, 0)
|
120
|
+
return(0, 0x20)
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk {
|
125
|
+
let _pPairing := add(pMem, pPairing)
|
126
|
+
let _pVk := add(pMem, pVk)
|
127
|
+
|
128
|
+
mstore(_pVk, IC0x)
|
129
|
+
mstore(add(_pVk, 32), IC0y)
|
130
|
+
|
131
|
+
// Compute the linear combination vk_x
|
132
|
+
|
133
|
+
g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0)))
|
134
|
+
|
135
|
+
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
|
136
|
+
|
137
|
+
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
|
138
|
+
|
139
|
+
g1_mulAccC(_pVk, IC4x, IC4y, calldataload(add(pubSignals, 96)))
|
140
|
+
|
141
|
+
g1_mulAccC(_pVk, IC5x, IC5y, calldataload(add(pubSignals, 128)))
|
142
|
+
|
143
|
+
g1_mulAccC(_pVk, IC6x, IC6y, calldataload(add(pubSignals, 160)))
|
144
|
+
|
145
|
+
g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192)))
|
146
|
+
|
147
|
+
g1_mulAccC(_pVk, IC8x, IC8y, calldataload(add(pubSignals, 224)))
|
148
|
+
|
149
|
+
g1_mulAccC(_pVk, IC9x, IC9y, calldataload(add(pubSignals, 256)))
|
150
|
+
|
151
|
+
g1_mulAccC(_pVk, IC10x, IC10y, calldataload(add(pubSignals, 288)))
|
152
|
+
|
153
|
+
g1_mulAccC(_pVk, IC11x, IC11y, calldataload(add(pubSignals, 320)))
|
154
|
+
|
155
|
+
|
156
|
+
// -A
|
157
|
+
mstore(_pPairing, calldataload(pA))
|
158
|
+
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
|
159
|
+
|
160
|
+
// B
|
161
|
+
mstore(add(_pPairing, 64), calldataload(pB))
|
162
|
+
mstore(add(_pPairing, 96), calldataload(add(pB, 32)))
|
163
|
+
mstore(add(_pPairing, 128), calldataload(add(pB, 64)))
|
164
|
+
mstore(add(_pPairing, 160), calldataload(add(pB, 96)))
|
165
|
+
|
166
|
+
// alpha1
|
167
|
+
mstore(add(_pPairing, 192), alphax)
|
168
|
+
mstore(add(_pPairing, 224), alphay)
|
169
|
+
|
170
|
+
// beta2
|
171
|
+
mstore(add(_pPairing, 256), betax1)
|
172
|
+
mstore(add(_pPairing, 288), betax2)
|
173
|
+
mstore(add(_pPairing, 320), betay1)
|
174
|
+
mstore(add(_pPairing, 352), betay2)
|
175
|
+
|
176
|
+
// vk_x
|
177
|
+
mstore(add(_pPairing, 384), mload(add(pMem, pVk)))
|
178
|
+
mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32))))
|
179
|
+
|
180
|
+
|
181
|
+
// gamma2
|
182
|
+
mstore(add(_pPairing, 448), gammax1)
|
183
|
+
mstore(add(_pPairing, 480), gammax2)
|
184
|
+
mstore(add(_pPairing, 512), gammay1)
|
185
|
+
mstore(add(_pPairing, 544), gammay2)
|
186
|
+
|
187
|
+
// C
|
188
|
+
mstore(add(_pPairing, 576), calldataload(pC))
|
189
|
+
mstore(add(_pPairing, 608), calldataload(add(pC, 32)))
|
190
|
+
|
191
|
+
// delta2
|
192
|
+
mstore(add(_pPairing, 640), deltax1)
|
193
|
+
mstore(add(_pPairing, 672), deltax2)
|
194
|
+
mstore(add(_pPairing, 704), deltay1)
|
195
|
+
mstore(add(_pPairing, 736), deltay2)
|
196
|
+
|
197
|
+
|
198
|
+
let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
|
199
|
+
|
200
|
+
isOk := and(success, mload(_pPairing))
|
201
|
+
}
|
202
|
+
|
203
|
+
let pMem := mload(0x40)
|
204
|
+
mstore(0x40, add(pMem, pLastMem))
|
205
|
+
|
206
|
+
// Validate that all evaluations ∈ F
|
207
|
+
|
208
|
+
checkField(calldataload(add(_pubSignals, 0)))
|
209
|
+
|
210
|
+
checkField(calldataload(add(_pubSignals, 32)))
|
211
|
+
|
212
|
+
checkField(calldataload(add(_pubSignals, 64)))
|
213
|
+
|
214
|
+
checkField(calldataload(add(_pubSignals, 96)))
|
215
|
+
|
216
|
+
checkField(calldataload(add(_pubSignals, 128)))
|
217
|
+
|
218
|
+
checkField(calldataload(add(_pubSignals, 160)))
|
219
|
+
|
220
|
+
checkField(calldataload(add(_pubSignals, 192)))
|
221
|
+
|
222
|
+
checkField(calldataload(add(_pubSignals, 224)))
|
223
|
+
|
224
|
+
checkField(calldataload(add(_pubSignals, 256)))
|
225
|
+
|
226
|
+
checkField(calldataload(add(_pubSignals, 288)))
|
227
|
+
|
228
|
+
checkField(calldataload(add(_pubSignals, 320)))
|
229
|
+
|
230
|
+
checkField(calldataload(add(_pubSignals, 352)))
|
231
|
+
|
232
|
+
|
233
|
+
// Validate all evaluations
|
234
|
+
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
|
235
|
+
|
236
|
+
mstore(0, isValid)
|
237
|
+
return(0, 0x20)
|
238
|
+
}
|
239
|
+
}
|
240
|
+
}
|