@lfdecentralizedtrust/zeto-contracts 0.2.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -162
- package/contracts/factory.sol +30 -34
- package/contracts/factory_upgradeable.sol +11 -7
- package/contracts/lib/common/util.sol +40 -0
- package/contracts/lib/interfaces/ILockableCapability.sol +318 -0
- package/contracts/lib/interfaces/{izeto.sol → IZeto.sol} +13 -1
- package/contracts/lib/interfaces/{izeto_initializable.sol → IZetoInitializable.sol} +14 -12
- package/contracts/lib/interfaces/{izeto_kyc.sol → IZetoKyc.sol} +3 -3
- package/contracts/lib/interfaces/IZetoLockableCapability.sol +237 -0
- package/contracts/lib/interfaces/IZetoStorage.sol +106 -0
- package/contracts/lib/interfaces/{izeto_lockable.sol → IZetoVerifier.sol} +8 -21
- package/contracts/lib/registry.sol +74 -26
- package/contracts/lib/storage/base.sol +210 -0
- package/contracts/lib/storage/nullifier.sol +166 -0
- package/contracts/lib/zeto_common.sol +277 -28
- package/contracts/lib/zeto_fungible.sol +451 -33
- package/contracts/lib/zeto_fungible_base.sol +69 -0
- package/contracts/lib/zeto_fungible_burn.sol +83 -53
- package/contracts/lib/zeto_fungible_burn_nullifier.sol +115 -72
- package/contracts/lib/zeto_fungible_nullifier.sol +167 -0
- package/contracts/lib/zeto_lockable.sol +613 -0
- package/contracts/lib/zeto_non_fungible.sol +236 -0
- package/contracts/lib/zeto_non_fungible_base.sol +61 -0
- package/contracts/lib/zeto_non_fungible_nullifier.sol +61 -0
- package/contracts/test/escrow1.sol +90 -34
- package/contracts/test/escrow2.sol +64 -29
- package/contracts/test/qurrency.sol +10 -2
- package/contracts/test/smt.sol +6 -1
- package/contracts/test/tendecimals.sol +14 -12
- package/contracts/verifiers/impl/anon.sol +189 -0
- package/contracts/verifiers/impl/anon_batch.sol +301 -0
- package/contracts/verifiers/impl/anon_enc.sol +266 -0
- package/contracts/verifiers/impl/anon_enc_batch.sol +602 -0
- package/contracts/verifiers/impl/anon_enc_nullifier.sol +287 -0
- package/contracts/verifiers/impl/anon_enc_nullifier_batch.sol +679 -0
- package/contracts/verifiers/impl/anon_enc_nullifier_kyc.sol +294 -0
- package/contracts/verifiers/impl/anon_enc_nullifier_kyc_batch.sol +686 -0
- package/contracts/verifiers/impl/anon_enc_nullifier_non_repudiation.sol +413 -0
- package/contracts/verifiers/impl/anon_enc_nullifier_non_repudiation_batch.sol +1141 -0
- package/contracts/verifiers/impl/anon_nullifier_kyc_transfer.sol +217 -0
- package/contracts/verifiers/impl/anon_nullifier_kyc_transferLocked.sol +196 -0
- package/contracts/verifiers/impl/anon_nullifier_kyc_transferLocked_batch.sol +308 -0
- package/contracts/verifiers/impl/anon_nullifier_kyc_transfer_batch.sol +385 -0
- package/contracts/verifiers/impl/anon_nullifier_qurrency_transfer.sol +497 -0
- package/contracts/verifiers/impl/anon_nullifier_qurrency_transfer_batch.sol +1001 -0
- package/contracts/verifiers/{verifier_anon_nullifier_transferLocked.sol → impl/anon_nullifier_transfer.sol} +12 -19
- package/contracts/verifiers/{verifier_anon_nullifier_transferLocked_batch.sol → impl/anon_nullifier_transfer_batch.sol} +44 -51
- package/contracts/verifiers/impl/burn.sol +182 -0
- package/contracts/verifiers/impl/burn_batch.sol +238 -0
- package/contracts/verifiers/impl/burn_nullifier.sol +203 -0
- package/contracts/verifiers/impl/burn_nullifier_batch.sol +315 -0
- package/contracts/verifiers/impl/deposit.sol +182 -0
- package/contracts/verifiers/impl/deposit_kyc.sol +189 -0
- package/contracts/verifiers/impl/nf_anon.sol +175 -0
- package/contracts/verifiers/{verifier_nf_anon_nullifier_transferLocked.sol → impl/nf_anon_nullifier_transfer.sol} +6 -13
- package/contracts/verifiers/impl/withdraw.sol +189 -0
- package/contracts/verifiers/impl/withdraw_batch.sol +245 -0
- package/contracts/verifiers/impl/withdraw_nullifier.sol +210 -0
- package/contracts/verifiers/impl/withdraw_nullifier_batch.sol +322 -0
- package/contracts/verifiers/verifier_anon.sol +31 -186
- package/contracts/verifiers/verifier_anon_batch.sol +31 -298
- package/contracts/verifiers/verifier_anon_enc.sol +31 -263
- package/contracts/verifiers/verifier_anon_enc_batch.sol +31 -599
- package/contracts/verifiers/verifier_anon_enc_nullifier.sol +31 -284
- package/contracts/verifiers/verifier_anon_enc_nullifier_batch.sol +33 -676
- package/contracts/verifiers/verifier_anon_enc_nullifier_kyc.sol +31 -291
- package/contracts/verifiers/verifier_anon_enc_nullifier_kyc_batch.sol +33 -683
- package/contracts/verifiers/verifier_anon_enc_nullifier_non_repudiation.sol +33 -410
- package/contracts/verifiers/verifier_anon_enc_nullifier_non_repudiation_batch.sol +33 -1138
- package/contracts/verifiers/verifier_anon_nullifier_kyc_transfer.sol +33 -214
- package/contracts/verifiers/verifier_anon_nullifier_kyc_transferLocked.sol +33 -221
- package/contracts/verifiers/verifier_anon_nullifier_kyc_transferLocked_batch.sol +33 -389
- package/contracts/verifiers/verifier_anon_nullifier_kyc_transfer_batch.sol +33 -382
- package/contracts/verifiers/verifier_anon_nullifier_qurrency_transfer.sol +33 -221
- package/contracts/verifiers/verifier_anon_nullifier_qurrency_transfer_batch.sol +33 -389
- package/contracts/verifiers/verifier_anon_nullifier_transfer.sol +33 -207
- package/contracts/verifiers/verifier_anon_nullifier_transfer_batch.sol +33 -375
- package/contracts/verifiers/verifier_burn.sol +31 -179
- package/contracts/verifiers/verifier_burn_batch.sol +31 -235
- package/contracts/verifiers/verifier_burn_nullifier.sol +31 -200
- package/contracts/verifiers/verifier_burn_nullifier_batch.sol +31 -312
- package/contracts/verifiers/verifier_deposit.sol +31 -179
- package/contracts/verifiers/verifier_deposit_kyc.sol +34 -0
- package/contracts/verifiers/verifier_nf_anon.sol +31 -172
- package/contracts/verifiers/verifier_nf_anon_nullifier_transfer.sol +33 -179
- package/contracts/verifiers/verifier_withdraw.sol +31 -186
- package/contracts/verifiers/verifier_withdraw_batch.sol +31 -242
- package/contracts/verifiers/verifier_withdraw_nullifier.sol +31 -207
- package/contracts/verifiers/verifier_withdraw_nullifier_batch.sol +33 -319
- package/contracts/zeto_anon.sol +77 -231
- package/contracts/zeto_anon_burnable.sol +56 -12
- package/contracts/zeto_anon_enc.sol +93 -190
- package/contracts/zeto_anon_enc_nullifier.sol +249 -195
- package/contracts/zeto_anon_enc_nullifier_kyc.sol +51 -232
- package/contracts/zeto_anon_enc_nullifier_non_repudiation.sol +231 -238
- package/contracts/zeto_anon_nullifier.sol +164 -298
- package/contracts/zeto_anon_nullifier_burnable.sol +68 -18
- package/contracts/zeto_anon_nullifier_kyc.sol +40 -345
- package/contracts/zeto_anon_nullifier_qurrency.sol +217 -361
- package/contracts/zeto_nf_anon.sol +55 -130
- package/contracts/zeto_nf_anon_nullifier.sol +90 -152
- package/hardhat.config.ts +9 -3
- package/ignition/modules/lib/deps.ts +8 -0
- package/ignition/modules/zeto_anon_burnable.ts +8 -7
- package/ignition/modules/zeto_anon_enc_nullifier.ts +31 -0
- package/ignition/modules/zeto_anon_enc_nullifier_kyc.ts +2 -2
- package/ignition/modules/zeto_anon_nullifier.ts +28 -4
- package/ignition/modules/zeto_anon_nullifier_burnable.ts +50 -16
- package/ignition/modules/zeto_anon_nullifier_kyc.ts +27 -12
- package/ignition/modules/zeto_nf_anon_nullifier.ts +14 -10
- package/package.json +4 -2
- package/scripts/deploy_cloneable.ts +19 -10
- package/scripts/deploy_upgradeable.ts +9 -5
- package/scripts/tokens/Zeto_Anon.ts +3 -3
- package/scripts/tokens/Zeto_AnonBurnable.ts +1 -1
- package/scripts/tokens/Zeto_AnonEnc.ts +12 -3
- package/scripts/tokens/Zeto_AnonEncNullifier.ts +5 -3
- package/scripts/tokens/Zeto_AnonEncNullifierKyc.ts +1 -1
- package/scripts/tokens/Zeto_AnonEncNullifierNonRepudiation.ts +1 -1
- package/scripts/tokens/Zeto_AnonNullifier.ts +1 -1
- package/scripts/tokens/Zeto_AnonNullifierBurnable.ts +1 -1
- package/scripts/tokens/Zeto_AnonNullifierKyc.ts +1 -1
- package/scripts/tokens/Zeto_AnonNullifierQurrency.ts +1 -1
- package/scripts/tokens/Zeto_NfAnon.ts +2 -2
- package/scripts/tokens/Zeto_NfAnonNullifier.ts +1 -1
- package/test/factory.ts +46 -73
- package/test/lib/anon_nullifier_helpers.ts +89 -0
- package/test/lib/anon_zeto_helpers.ts +76 -0
- package/test/lib/deploy.ts +3 -2
- package/test/lib/utils.ts +74 -35
- package/test/test/escrow1.ts +185 -58
- package/test/test/escrow2.ts +200 -107
- package/test/test/qurrency.ts +13 -33
- package/test/usdc-shielding.ts +39 -26
- package/test/utils.ts +144 -21
- package/test/zeto_anon.ts +956 -465
- package/test/zeto_anon_enc.ts +881 -142
- package/test/zeto_anon_enc_nullifier.ts +847 -38
- package/test/zeto_anon_enc_nullifier_kyc.ts +120 -181
- package/test/zeto_anon_enc_nullifier_non_repudiation.ts +77 -46
- package/test/zeto_anon_nullifier.ts +1212 -953
- package/test/zeto_anon_nullifier_kyc.ts +674 -655
- package/test/zeto_anon_nullifier_qurrency.ts +452 -306
- package/test/zeto_nf_anon.ts +737 -137
- package/test/zeto_nf_anon_nullifier.ts +876 -246
- package/contracts/lib/zeto_base.sol +0 -293
- package/contracts/lib/zeto_fungible_withdraw.sol +0 -132
- package/contracts/lib/zeto_fungible_withdraw_nullifier.sol +0 -144
- package/contracts/lib/zeto_nullifier.sol +0 -340
- package/contracts/zkDvP.sol_ +0 -273
- package/test/zkDvP.ts_ +0 -455
- /package/contracts/lib/{common.sol → common/common.sol} +0 -0
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
pragma solidity >=0.7.0 <0.9.0;
|
|
22
22
|
|
|
23
|
-
contract
|
|
23
|
+
contract Verifier_AnonNullifierTransfer {
|
|
24
24
|
// Scalar field size
|
|
25
25
|
uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
|
|
26
26
|
// Base field size
|
|
@@ -52,23 +52,20 @@ contract Groth16Verifier_AnonNullifierTransferLocked {
|
|
|
52
52
|
uint256 constant IC2x = 11538009073536561162431603046042378506434129710246113579796569619470355977356;
|
|
53
53
|
uint256 constant IC2y = 18200656560016022729405688044864673805927167342575989505621039477255562885095;
|
|
54
54
|
|
|
55
|
-
uint256 constant IC3x =
|
|
56
|
-
uint256 constant IC3y =
|
|
55
|
+
uint256 constant IC3x = 16060424900281789113856869053727496302295520075201955371229184101176742019112;
|
|
56
|
+
uint256 constant IC3y = 7833246346420318094523191406657909832948492362877179000610063345430143769697;
|
|
57
57
|
|
|
58
|
-
uint256 constant IC4x =
|
|
59
|
-
uint256 constant IC4y =
|
|
58
|
+
uint256 constant IC4x = 1167903139320461673730146790352309165100002152797819099757601178981873676571;
|
|
59
|
+
uint256 constant IC4y = 12981611873802789105958141408359145370994325864169284450155625189242411024122;
|
|
60
60
|
|
|
61
|
-
uint256 constant IC5x =
|
|
62
|
-
uint256 constant IC5y =
|
|
61
|
+
uint256 constant IC5x = 20773020415848698598468478160768655922713869022241397741152588611764469765759;
|
|
62
|
+
uint256 constant IC5y = 3428403864418547287693751509569561378183428598972823612146679585580293690972;
|
|
63
63
|
|
|
64
|
-
uint256 constant IC6x =
|
|
65
|
-
uint256 constant IC6y =
|
|
64
|
+
uint256 constant IC6x = 15674579346918082060062949471055203685989363986238424085033128428743473529013;
|
|
65
|
+
uint256 constant IC6y = 9126381316540146842373796334750733369806543224338767018342599704279030186328;
|
|
66
66
|
|
|
67
|
-
uint256 constant IC7x =
|
|
68
|
-
uint256 constant IC7y =
|
|
69
|
-
|
|
70
|
-
uint256 constant IC8x = 15590566039348482609378805660317581071082774252842945453976612859375632192241;
|
|
71
|
-
uint256 constant IC8y = 7414583059436497224674542800033160660870802119716266452150429658361893709028;
|
|
67
|
+
uint256 constant IC7x = 17375655877097475551894724405341759891777951116707914297938348038970054234761;
|
|
68
|
+
uint256 constant IC7y = 17844212665933336469595879705672773898766845640145736759052525282105784315179;
|
|
72
69
|
|
|
73
70
|
|
|
74
71
|
// Memory data
|
|
@@ -77,7 +74,7 @@ contract Groth16Verifier_AnonNullifierTransferLocked {
|
|
|
77
74
|
|
|
78
75
|
uint16 constant pLastMem = 896;
|
|
79
76
|
|
|
80
|
-
function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[
|
|
77
|
+
function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[7] calldata _pubSignals) public view returns (bool) {
|
|
81
78
|
assembly {
|
|
82
79
|
function checkField(v) {
|
|
83
80
|
if iszero(lt(v, r)) {
|
|
@@ -135,8 +132,6 @@ contract Groth16Verifier_AnonNullifierTransferLocked {
|
|
|
135
132
|
|
|
136
133
|
g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192)))
|
|
137
134
|
|
|
138
|
-
g1_mulAccC(_pVk, IC8x, IC8y, calldataload(add(pubSignals, 224)))
|
|
139
|
-
|
|
140
135
|
|
|
141
136
|
// -A
|
|
142
137
|
mstore(_pPairing, calldataload(pA))
|
|
@@ -204,8 +199,6 @@ contract Groth16Verifier_AnonNullifierTransferLocked {
|
|
|
204
199
|
|
|
205
200
|
checkField(calldataload(add(_pubSignals, 192)))
|
|
206
201
|
|
|
207
|
-
checkField(calldataload(add(_pubSignals, 224)))
|
|
208
|
-
|
|
209
202
|
|
|
210
203
|
// Validate all evaluations
|
|
211
204
|
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
pragma solidity >=0.7.0 <0.9.0;
|
|
22
22
|
|
|
23
|
-
contract
|
|
23
|
+
contract Verifier_AnonNullifierTransferBatch {
|
|
24
24
|
// Scalar field size
|
|
25
25
|
uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
|
|
26
26
|
// Base field size
|
|
@@ -76,71 +76,68 @@ contract Groth16Verifier_AnonNullifierTransferLockedBatch {
|
|
|
76
76
|
uint256 constant IC10x = 6520359164220525265155386274709266517766289259436803139853734621791509514404;
|
|
77
77
|
uint256 constant IC10y = 21368162840781823986174234261008274176487028095574542697455308297011056522636;
|
|
78
78
|
|
|
79
|
-
uint256 constant IC11x =
|
|
80
|
-
uint256 constant IC11y =
|
|
79
|
+
uint256 constant IC11x = 11986049124283047338689275016354659993085995403687773059614159878672406545037;
|
|
80
|
+
uint256 constant IC11y = 1720839942816430712816903108884813241869643182010336846593958574729389440480;
|
|
81
81
|
|
|
82
|
-
uint256 constant IC12x =
|
|
83
|
-
uint256 constant IC12y =
|
|
82
|
+
uint256 constant IC12x = 12410983687677574157893657225675183803303132301532659422552214052530726469317;
|
|
83
|
+
uint256 constant IC12y = 17824345118891411719771382010799290239467606961339235068922789659663655509754;
|
|
84
84
|
|
|
85
|
-
uint256 constant IC13x =
|
|
86
|
-
uint256 constant IC13y =
|
|
85
|
+
uint256 constant IC13x = 19444872974172689434561725816869098654627826005137317657361016988886067248336;
|
|
86
|
+
uint256 constant IC13y = 3172141317144739547875932810700616635313442420128093386048940765681131092361;
|
|
87
87
|
|
|
88
|
-
uint256 constant IC14x =
|
|
89
|
-
uint256 constant IC14y =
|
|
88
|
+
uint256 constant IC14x = 6341822874573516725445274172596187511776250848357140465985666938085067778605;
|
|
89
|
+
uint256 constant IC14y = 10990036049763065187228663840382596985383914188335629682023429665320288002265;
|
|
90
90
|
|
|
91
|
-
uint256 constant IC15x =
|
|
92
|
-
uint256 constant IC15y =
|
|
91
|
+
uint256 constant IC15x = 3563685232497885739427596637416450424787463707609627934104367359850504982303;
|
|
92
|
+
uint256 constant IC15y = 14523974417703319423058515825317379629896605049279696879645515541999709097899;
|
|
93
93
|
|
|
94
|
-
uint256 constant IC16x =
|
|
95
|
-
uint256 constant IC16y =
|
|
94
|
+
uint256 constant IC16x = 10426055994788300403026220351488163197517295733007869321776166355731683467471;
|
|
95
|
+
uint256 constant IC16y = 18175812088634093492623689292236125764292351272021854381676202255919008010343;
|
|
96
96
|
|
|
97
|
-
uint256 constant IC17x =
|
|
98
|
-
uint256 constant IC17y =
|
|
97
|
+
uint256 constant IC17x = 3950389660730108543529631996339492738202948080219082719068949318015974186960;
|
|
98
|
+
uint256 constant IC17y = 2727547245375504168114490191114505397213374496025773532049654614435667570690;
|
|
99
99
|
|
|
100
|
-
uint256 constant IC18x =
|
|
101
|
-
uint256 constant IC18y =
|
|
100
|
+
uint256 constant IC18x = 8878853611820647211708603584241467289939654374955042014923131062893095601257;
|
|
101
|
+
uint256 constant IC18y = 13640555931452954554478583351999961428703214573943103283873522300398348512261;
|
|
102
102
|
|
|
103
|
-
uint256 constant IC19x =
|
|
104
|
-
uint256 constant IC19y =
|
|
103
|
+
uint256 constant IC19x = 19706318980768223269467987992862357090252614480154835271757186053712302707054;
|
|
104
|
+
uint256 constant IC19y = 3550479890941383303746854615447654371345839372883939502972660199314609198224;
|
|
105
105
|
|
|
106
|
-
uint256 constant IC20x =
|
|
107
|
-
uint256 constant IC20y =
|
|
106
|
+
uint256 constant IC20x = 13754703141709110513251981557546245368692890422611576710774721290436667971547;
|
|
107
|
+
uint256 constant IC20y = 15622915412029160187321643908593105738313134938831581567824879502136844415106;
|
|
108
108
|
|
|
109
|
-
uint256 constant IC21x =
|
|
110
|
-
uint256 constant IC21y =
|
|
109
|
+
uint256 constant IC21x = 12878657066345957537439144048759746489348595042995392127741332409892311328989;
|
|
110
|
+
uint256 constant IC21y = 5634533423081799906181954901378182109129522944123920261387973446573637973526;
|
|
111
111
|
|
|
112
|
-
uint256 constant IC22x =
|
|
113
|
-
uint256 constant IC22y =
|
|
112
|
+
uint256 constant IC22x = 1747558549104994006853755338447511580410928014353375959457633482435305339657;
|
|
113
|
+
uint256 constant IC22y = 16693561381938465114233116706143740771384240170854874824494628919950181351869;
|
|
114
114
|
|
|
115
|
-
uint256 constant IC23x =
|
|
116
|
-
uint256 constant IC23y =
|
|
115
|
+
uint256 constant IC23x = 1613138279337931031857254936115331776171624220704338069120610390082066380417;
|
|
116
|
+
uint256 constant IC23y = 8417894649949518720347097876791220132985676261354432557373036131639583799446;
|
|
117
117
|
|
|
118
|
-
uint256 constant IC24x =
|
|
119
|
-
uint256 constant IC24y =
|
|
118
|
+
uint256 constant IC24x = 15376107650432532562517675238879931109183652385872341741350057207069919760677;
|
|
119
|
+
uint256 constant IC24y = 12163613282894312110952413452590943793689556977608429079525501424245210898987;
|
|
120
120
|
|
|
121
|
-
uint256 constant IC25x =
|
|
122
|
-
uint256 constant IC25y =
|
|
121
|
+
uint256 constant IC25x = 21087166981062958259825865347134564875926186819875767696568317823488336917896;
|
|
122
|
+
uint256 constant IC25y = 15762649107811141917603699122632018793639916612208894025714649072338044075586;
|
|
123
123
|
|
|
124
|
-
uint256 constant IC26x =
|
|
125
|
-
uint256 constant IC26y =
|
|
124
|
+
uint256 constant IC26x = 5120686049886825058445452951254266343462561773672356770732157430858330491691;
|
|
125
|
+
uint256 constant IC26y = 11046045856891422237147253594749318345951196586790871800156338688334664797048;
|
|
126
126
|
|
|
127
|
-
uint256 constant IC27x =
|
|
128
|
-
uint256 constant IC27y =
|
|
127
|
+
uint256 constant IC27x = 11116873825396655991389216659269585145620200225791557320551530972352228098831;
|
|
128
|
+
uint256 constant IC27y = 3271191376177107978938083722391105421120848315078198802353087459617997426104;
|
|
129
129
|
|
|
130
|
-
uint256 constant IC28x =
|
|
131
|
-
uint256 constant IC28y =
|
|
130
|
+
uint256 constant IC28x = 21019143498004400903259766749142372667153376608389483897878881810132865116542;
|
|
131
|
+
uint256 constant IC28y = 20058271295969084519220780794685774075235178554301385873847280275673893710867;
|
|
132
132
|
|
|
133
|
-
uint256 constant IC29x =
|
|
134
|
-
uint256 constant IC29y =
|
|
133
|
+
uint256 constant IC29x = 3088320503719486244878902559682118797941031906918592703374618231044866477933;
|
|
134
|
+
uint256 constant IC29y = 7957746217390961233365848173642960838604761579306585693479441876449511811100;
|
|
135
135
|
|
|
136
|
-
uint256 constant IC30x =
|
|
137
|
-
uint256 constant IC30y =
|
|
136
|
+
uint256 constant IC30x = 9265264187620997738961784598279326190924030246353391735448996655308762594393;
|
|
137
|
+
uint256 constant IC30y = 12870913899766817882209478409287941761615618579244334984219588810560763939529;
|
|
138
138
|
|
|
139
|
-
uint256 constant IC31x =
|
|
140
|
-
uint256 constant IC31y =
|
|
141
|
-
|
|
142
|
-
uint256 constant IC32x = 16597903527154606469004098702646630646876098326443455720293607746691316479676;
|
|
143
|
-
uint256 constant IC32y = 6865378811596695553676917046222081530105365855806005223865134455501995569693;
|
|
139
|
+
uint256 constant IC31x = 5254797586690949845864066912241731823062919857632449946826426119537257133607;
|
|
140
|
+
uint256 constant IC31y = 6442862733198819845417622717002423202646999126954588221448840906596194569308;
|
|
144
141
|
|
|
145
142
|
|
|
146
143
|
// Memory data
|
|
@@ -149,7 +146,7 @@ contract Groth16Verifier_AnonNullifierTransferLockedBatch {
|
|
|
149
146
|
|
|
150
147
|
uint16 constant pLastMem = 896;
|
|
151
148
|
|
|
152
|
-
function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[
|
|
149
|
+
function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[31] calldata _pubSignals) public view returns (bool) {
|
|
153
150
|
assembly {
|
|
154
151
|
function checkField(v) {
|
|
155
152
|
if iszero(lt(v, r)) {
|
|
@@ -255,8 +252,6 @@ contract Groth16Verifier_AnonNullifierTransferLockedBatch {
|
|
|
255
252
|
|
|
256
253
|
g1_mulAccC(_pVk, IC31x, IC31y, calldataload(add(pubSignals, 960)))
|
|
257
254
|
|
|
258
|
-
g1_mulAccC(_pVk, IC32x, IC32y, calldataload(add(pubSignals, 992)))
|
|
259
|
-
|
|
260
255
|
|
|
261
256
|
// -A
|
|
262
257
|
mstore(_pPairing, calldataload(pA))
|
|
@@ -372,8 +367,6 @@ contract Groth16Verifier_AnonNullifierTransferLockedBatch {
|
|
|
372
367
|
|
|
373
368
|
checkField(calldataload(add(_pubSignals, 960)))
|
|
374
369
|
|
|
375
|
-
checkField(calldataload(add(_pubSignals, 992)))
|
|
376
|
-
|
|
377
370
|
|
|
378
371
|
// Validate all evaluations
|
|
379
372
|
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
|
|
@@ -0,0 +1,182 @@
|
|
|
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 Verifier_Burn {
|
|
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 = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
|
|
31
|
+
uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
|
|
32
|
+
uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
|
|
33
|
+
uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
|
|
34
|
+
uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
|
|
35
|
+
uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
|
|
36
|
+
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
|
|
37
|
+
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
|
|
38
|
+
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
|
|
39
|
+
uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
|
|
40
|
+
uint256 constant deltax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
|
|
41
|
+
uint256 constant deltax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
|
|
42
|
+
uint256 constant deltay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
|
|
43
|
+
uint256 constant deltay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
uint256 constant IC0x = 14207649465847074459006551899801105360344045193984915354386078270967717414662;
|
|
47
|
+
uint256 constant IC0y = 14203847703207394749659860962890233765723282136337244239517265306071139670341;
|
|
48
|
+
|
|
49
|
+
uint256 constant IC1x = 20991582431635387746090800929038448868620958869834707086238456083408640908280;
|
|
50
|
+
uint256 constant IC1y = 10783061735315001386299657272927752303784112081871401453945754602227431478666;
|
|
51
|
+
|
|
52
|
+
uint256 constant IC2x = 14006692811194189103148787387025604948395366969003356155170114368180461113393;
|
|
53
|
+
uint256 constant IC2y = 5673528144716202191549186015609073881678333688057753432182528489420085303744;
|
|
54
|
+
|
|
55
|
+
uint256 constant IC3x = 6162733910454695011371515613073936194378338628226525781838980758673160026926;
|
|
56
|
+
uint256 constant IC3y = 9898958851889443370118359024776281414454075518118600633160570171981761207967;
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
// Memory data
|
|
60
|
+
uint16 constant pVk = 0;
|
|
61
|
+
uint16 constant pPairing = 128;
|
|
62
|
+
|
|
63
|
+
uint16 constant pLastMem = 896;
|
|
64
|
+
|
|
65
|
+
function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[3] calldata _pubSignals) public view returns (bool) {
|
|
66
|
+
assembly {
|
|
67
|
+
function checkField(v) {
|
|
68
|
+
if iszero(lt(v, r)) {
|
|
69
|
+
mstore(0, 0)
|
|
70
|
+
return(0, 0x20)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// G1 function to multiply a G1 value(x,y) to value in an address
|
|
75
|
+
function g1_mulAccC(pR, x, y, s) {
|
|
76
|
+
let success
|
|
77
|
+
let mIn := mload(0x40)
|
|
78
|
+
mstore(mIn, x)
|
|
79
|
+
mstore(add(mIn, 32), y)
|
|
80
|
+
mstore(add(mIn, 64), s)
|
|
81
|
+
|
|
82
|
+
success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
|
|
83
|
+
|
|
84
|
+
if iszero(success) {
|
|
85
|
+
mstore(0, 0)
|
|
86
|
+
return(0, 0x20)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
mstore(add(mIn, 64), mload(pR))
|
|
90
|
+
mstore(add(mIn, 96), mload(add(pR, 32)))
|
|
91
|
+
|
|
92
|
+
success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
|
|
93
|
+
|
|
94
|
+
if iszero(success) {
|
|
95
|
+
mstore(0, 0)
|
|
96
|
+
return(0, 0x20)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk {
|
|
101
|
+
let _pPairing := add(pMem, pPairing)
|
|
102
|
+
let _pVk := add(pMem, pVk)
|
|
103
|
+
|
|
104
|
+
mstore(_pVk, IC0x)
|
|
105
|
+
mstore(add(_pVk, 32), IC0y)
|
|
106
|
+
|
|
107
|
+
// Compute the linear combination vk_x
|
|
108
|
+
|
|
109
|
+
g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0)))
|
|
110
|
+
|
|
111
|
+
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
|
|
112
|
+
|
|
113
|
+
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
// -A
|
|
117
|
+
mstore(_pPairing, calldataload(pA))
|
|
118
|
+
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
|
|
119
|
+
|
|
120
|
+
// B
|
|
121
|
+
mstore(add(_pPairing, 64), calldataload(pB))
|
|
122
|
+
mstore(add(_pPairing, 96), calldataload(add(pB, 32)))
|
|
123
|
+
mstore(add(_pPairing, 128), calldataload(add(pB, 64)))
|
|
124
|
+
mstore(add(_pPairing, 160), calldataload(add(pB, 96)))
|
|
125
|
+
|
|
126
|
+
// alpha1
|
|
127
|
+
mstore(add(_pPairing, 192), alphax)
|
|
128
|
+
mstore(add(_pPairing, 224), alphay)
|
|
129
|
+
|
|
130
|
+
// beta2
|
|
131
|
+
mstore(add(_pPairing, 256), betax1)
|
|
132
|
+
mstore(add(_pPairing, 288), betax2)
|
|
133
|
+
mstore(add(_pPairing, 320), betay1)
|
|
134
|
+
mstore(add(_pPairing, 352), betay2)
|
|
135
|
+
|
|
136
|
+
// vk_x
|
|
137
|
+
mstore(add(_pPairing, 384), mload(add(pMem, pVk)))
|
|
138
|
+
mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32))))
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
// gamma2
|
|
142
|
+
mstore(add(_pPairing, 448), gammax1)
|
|
143
|
+
mstore(add(_pPairing, 480), gammax2)
|
|
144
|
+
mstore(add(_pPairing, 512), gammay1)
|
|
145
|
+
mstore(add(_pPairing, 544), gammay2)
|
|
146
|
+
|
|
147
|
+
// C
|
|
148
|
+
mstore(add(_pPairing, 576), calldataload(pC))
|
|
149
|
+
mstore(add(_pPairing, 608), calldataload(add(pC, 32)))
|
|
150
|
+
|
|
151
|
+
// delta2
|
|
152
|
+
mstore(add(_pPairing, 640), deltax1)
|
|
153
|
+
mstore(add(_pPairing, 672), deltax2)
|
|
154
|
+
mstore(add(_pPairing, 704), deltay1)
|
|
155
|
+
mstore(add(_pPairing, 736), deltay2)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
|
|
159
|
+
|
|
160
|
+
isOk := and(success, mload(_pPairing))
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
let pMem := mload(0x40)
|
|
164
|
+
mstore(0x40, add(pMem, pLastMem))
|
|
165
|
+
|
|
166
|
+
// Validate that all evaluations ∈ F
|
|
167
|
+
|
|
168
|
+
checkField(calldataload(add(_pubSignals, 0)))
|
|
169
|
+
|
|
170
|
+
checkField(calldataload(add(_pubSignals, 32)))
|
|
171
|
+
|
|
172
|
+
checkField(calldataload(add(_pubSignals, 64)))
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
// Validate all evaluations
|
|
176
|
+
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
|
|
177
|
+
|
|
178
|
+
mstore(0, isValid)
|
|
179
|
+
return(0, 0x20)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
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 Verifier_BurnBatch {
|
|
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 = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
|
|
31
|
+
uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
|
|
32
|
+
uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
|
|
33
|
+
uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
|
|
34
|
+
uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
|
|
35
|
+
uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
|
|
36
|
+
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
|
|
37
|
+
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
|
|
38
|
+
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
|
|
39
|
+
uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
|
|
40
|
+
uint256 constant deltax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
|
|
41
|
+
uint256 constant deltax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
|
|
42
|
+
uint256 constant deltay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
|
|
43
|
+
uint256 constant deltay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
uint256 constant IC0x = 7631257906107650252600145723888878222116317244029552711162468092756937492692;
|
|
47
|
+
uint256 constant IC0y = 21533439902964678059972645672295063253017913469233699615769382673890163442989;
|
|
48
|
+
|
|
49
|
+
uint256 constant IC1x = 1452116139955566603194478923716910101802496934152744867265527791250404038823;
|
|
50
|
+
uint256 constant IC1y = 6673542924818916509202846631770828428780632369731800323285779288715125663589;
|
|
51
|
+
|
|
52
|
+
uint256 constant IC2x = 7420056446893507736984550520579335657278263462589586131787103166599640463478;
|
|
53
|
+
uint256 constant IC2y = 15975062804917941696207231021230248919824358958350174816797234388427655512882;
|
|
54
|
+
|
|
55
|
+
uint256 constant IC3x = 3671066312224999073665280455061768923412039416115707772601043596926286431278;
|
|
56
|
+
uint256 constant IC3y = 2677952671086594665255013146125932150995484950543368552641379515907256501003;
|
|
57
|
+
|
|
58
|
+
uint256 constant IC4x = 20773542083028731773382992271757996563109613809271335566652212304600047070091;
|
|
59
|
+
uint256 constant IC4y = 4127534931003107599356004838413250277935814851296724893875709823794065306505;
|
|
60
|
+
|
|
61
|
+
uint256 constant IC5x = 10341004646478092931355681616660382693902678512482677938125005887124316152765;
|
|
62
|
+
uint256 constant IC5y = 7923464261944844839205065292580326683188404716466262258956809956184590021761;
|
|
63
|
+
|
|
64
|
+
uint256 constant IC6x = 6779471029284756918162956883720127063236000026616043850873659326220351759164;
|
|
65
|
+
uint256 constant IC6y = 3363099043577458891348004651430331031933902732546825484112862780494882706345;
|
|
66
|
+
|
|
67
|
+
uint256 constant IC7x = 3643583922845363299324866982994565910128232221293173155892149319988212291914;
|
|
68
|
+
uint256 constant IC7y = 19361444849011000229658521500930422347828327395570485178056706722338361925130;
|
|
69
|
+
|
|
70
|
+
uint256 constant IC8x = 13770709707251326390999117178934284613506760387725864815634125535930222646522;
|
|
71
|
+
uint256 constant IC8y = 21800266370933077493571039770074679032281564373672646405217493746190607957218;
|
|
72
|
+
|
|
73
|
+
uint256 constant IC9x = 5806904013223972450761771117316723363768298169000699993638559554524950945770;
|
|
74
|
+
uint256 constant IC9y = 18543558357419593215531073075248309048964681146029999482511740458059720449689;
|
|
75
|
+
|
|
76
|
+
uint256 constant IC10x = 18320219688608829968075030384893825876458562520853056684465492113328876872578;
|
|
77
|
+
uint256 constant IC10y = 13479039050249889368250244419835364693499574538369869489319903643150801464206;
|
|
78
|
+
|
|
79
|
+
uint256 constant IC11x = 851671849735031126345893979530598322453966429040751705913475255243208778752;
|
|
80
|
+
uint256 constant IC11y = 10153380221453105148515421084979735587724520574654009426957875693321035012414;
|
|
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, r)) {
|
|
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
|
+
|
|
231
|
+
// Validate all evaluations
|
|
232
|
+
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
|
|
233
|
+
|
|
234
|
+
mstore(0, isValid)
|
|
235
|
+
return(0, 0x20)
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|