@lfdecentralizedtrust/zeto-contracts 0.2.1 → 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.
Files changed (155) hide show
  1. package/README.md +70 -162
  2. package/contracts/factory.sol +30 -34
  3. package/contracts/factory_upgradeable.sol +160 -0
  4. package/contracts/lib/common/util.sol +40 -0
  5. package/contracts/lib/interfaces/ILockableCapability.sol +318 -0
  6. package/contracts/lib/interfaces/{izeto.sol → IZeto.sol} +13 -1
  7. package/contracts/lib/interfaces/{izeto_initializable.sol → IZetoInitializable.sol} +14 -12
  8. package/contracts/lib/interfaces/{izeto_kyc.sol → IZetoKyc.sol} +3 -3
  9. package/contracts/lib/interfaces/IZetoLockableCapability.sol +237 -0
  10. package/contracts/lib/interfaces/IZetoStorage.sol +106 -0
  11. package/contracts/lib/interfaces/{izeto_lockable.sol → IZetoVerifier.sol} +8 -21
  12. package/contracts/lib/registry.sol +77 -27
  13. package/contracts/lib/storage/base.sol +210 -0
  14. package/contracts/lib/storage/nullifier.sol +166 -0
  15. package/contracts/lib/zeto_common.sol +277 -28
  16. package/contracts/lib/zeto_fungible.sol +451 -33
  17. package/contracts/lib/zeto_fungible_base.sol +69 -0
  18. package/contracts/lib/zeto_fungible_burn.sol +83 -53
  19. package/contracts/lib/zeto_fungible_burn_nullifier.sol +115 -72
  20. package/contracts/lib/zeto_fungible_nullifier.sol +167 -0
  21. package/contracts/lib/zeto_lockable.sol +613 -0
  22. package/contracts/lib/zeto_non_fungible.sol +236 -0
  23. package/contracts/lib/zeto_non_fungible_base.sol +61 -0
  24. package/contracts/lib/zeto_non_fungible_nullifier.sol +61 -0
  25. package/contracts/test/escrow1.sol +90 -34
  26. package/contracts/test/escrow2.sol +64 -29
  27. package/contracts/test/qurrency.sol +10 -2
  28. package/contracts/test/smt.sol +8 -3
  29. package/contracts/test/tendecimals.sol +14 -12
  30. package/contracts/verifiers/impl/anon.sol +189 -0
  31. package/contracts/verifiers/impl/anon_batch.sol +301 -0
  32. package/contracts/verifiers/impl/anon_enc.sol +266 -0
  33. package/contracts/verifiers/impl/anon_enc_batch.sol +602 -0
  34. package/contracts/verifiers/impl/anon_enc_nullifier.sol +287 -0
  35. package/contracts/verifiers/impl/anon_enc_nullifier_batch.sol +679 -0
  36. package/contracts/verifiers/impl/anon_enc_nullifier_kyc.sol +294 -0
  37. package/contracts/verifiers/impl/anon_enc_nullifier_kyc_batch.sol +686 -0
  38. package/contracts/verifiers/impl/anon_enc_nullifier_non_repudiation.sol +413 -0
  39. package/contracts/verifiers/impl/anon_enc_nullifier_non_repudiation_batch.sol +1141 -0
  40. package/contracts/verifiers/impl/anon_nullifier_kyc_transfer.sol +217 -0
  41. package/contracts/verifiers/impl/anon_nullifier_kyc_transferLocked.sol +196 -0
  42. package/contracts/verifiers/impl/anon_nullifier_kyc_transferLocked_batch.sol +308 -0
  43. package/contracts/verifiers/impl/anon_nullifier_kyc_transfer_batch.sol +385 -0
  44. package/contracts/verifiers/impl/anon_nullifier_qurrency_transfer.sol +497 -0
  45. package/contracts/verifiers/impl/anon_nullifier_qurrency_transfer_batch.sol +1001 -0
  46. package/contracts/verifiers/{verifier_anon_nullifier_transferLocked.sol → impl/anon_nullifier_transfer.sol} +12 -19
  47. package/contracts/verifiers/{verifier_anon_nullifier_transferLocked_batch.sol → impl/anon_nullifier_transfer_batch.sol} +44 -51
  48. package/contracts/verifiers/impl/burn.sol +182 -0
  49. package/contracts/verifiers/impl/burn_batch.sol +238 -0
  50. package/contracts/verifiers/impl/burn_nullifier.sol +203 -0
  51. package/contracts/verifiers/impl/burn_nullifier_batch.sol +315 -0
  52. package/contracts/verifiers/impl/deposit.sol +182 -0
  53. package/contracts/verifiers/impl/deposit_kyc.sol +189 -0
  54. package/contracts/verifiers/impl/nf_anon.sol +175 -0
  55. package/contracts/verifiers/{verifier_nf_anon_nullifier_transferLocked.sol → impl/nf_anon_nullifier_transfer.sol} +6 -13
  56. package/contracts/verifiers/impl/withdraw.sol +189 -0
  57. package/contracts/verifiers/impl/withdraw_batch.sol +245 -0
  58. package/contracts/verifiers/impl/withdraw_nullifier.sol +210 -0
  59. package/contracts/verifiers/impl/withdraw_nullifier_batch.sol +322 -0
  60. package/contracts/verifiers/verifier_anon.sol +31 -186
  61. package/contracts/verifiers/verifier_anon_batch.sol +31 -298
  62. package/contracts/verifiers/verifier_anon_enc.sol +31 -263
  63. package/contracts/verifiers/verifier_anon_enc_batch.sol +31 -599
  64. package/contracts/verifiers/verifier_anon_enc_nullifier.sol +31 -284
  65. package/contracts/verifiers/verifier_anon_enc_nullifier_batch.sol +33 -676
  66. package/contracts/verifiers/verifier_anon_enc_nullifier_kyc.sol +31 -291
  67. package/contracts/verifiers/verifier_anon_enc_nullifier_kyc_batch.sol +33 -683
  68. package/contracts/verifiers/verifier_anon_enc_nullifier_non_repudiation.sol +33 -410
  69. package/contracts/verifiers/verifier_anon_enc_nullifier_non_repudiation_batch.sol +33 -1138
  70. package/contracts/verifiers/verifier_anon_nullifier_kyc_transfer.sol +33 -214
  71. package/contracts/verifiers/verifier_anon_nullifier_kyc_transferLocked.sol +33 -221
  72. package/contracts/verifiers/verifier_anon_nullifier_kyc_transferLocked_batch.sol +33 -389
  73. package/contracts/verifiers/verifier_anon_nullifier_kyc_transfer_batch.sol +33 -382
  74. package/contracts/verifiers/verifier_anon_nullifier_qurrency_transfer.sol +33 -221
  75. package/contracts/verifiers/verifier_anon_nullifier_qurrency_transfer_batch.sol +33 -389
  76. package/contracts/verifiers/verifier_anon_nullifier_transfer.sol +33 -207
  77. package/contracts/verifiers/verifier_anon_nullifier_transfer_batch.sol +33 -375
  78. package/contracts/verifiers/verifier_burn.sol +31 -179
  79. package/contracts/verifiers/verifier_burn_batch.sol +31 -235
  80. package/contracts/verifiers/verifier_burn_nullifier.sol +31 -200
  81. package/contracts/verifiers/verifier_burn_nullifier_batch.sol +31 -312
  82. package/contracts/verifiers/verifier_deposit.sol +31 -179
  83. package/contracts/verifiers/verifier_deposit_kyc.sol +34 -0
  84. package/contracts/verifiers/verifier_nf_anon.sol +31 -172
  85. package/contracts/verifiers/verifier_nf_anon_nullifier_transfer.sol +33 -179
  86. package/contracts/verifiers/verifier_withdraw.sol +31 -186
  87. package/contracts/verifiers/verifier_withdraw_batch.sol +31 -242
  88. package/contracts/verifiers/verifier_withdraw_nullifier.sol +31 -207
  89. package/contracts/verifiers/verifier_withdraw_nullifier_batch.sol +33 -319
  90. package/contracts/zeto_anon.sol +77 -231
  91. package/contracts/zeto_anon_burnable.sol +56 -12
  92. package/contracts/zeto_anon_enc.sol +93 -190
  93. package/contracts/zeto_anon_enc_nullifier.sol +249 -195
  94. package/contracts/zeto_anon_enc_nullifier_kyc.sol +51 -232
  95. package/contracts/zeto_anon_enc_nullifier_non_repudiation.sol +231 -238
  96. package/contracts/zeto_anon_nullifier.sol +164 -298
  97. package/contracts/zeto_anon_nullifier_burnable.sol +68 -18
  98. package/contracts/zeto_anon_nullifier_kyc.sol +40 -345
  99. package/contracts/zeto_anon_nullifier_qurrency.sol +218 -360
  100. package/contracts/zeto_nf_anon.sol +55 -130
  101. package/contracts/zeto_nf_anon_nullifier.sol +90 -152
  102. package/hardhat.config.ts +9 -3
  103. package/ignition/modules/lib/deps.ts +9 -6
  104. package/ignition/modules/zeto_anon_burnable.ts +8 -7
  105. package/ignition/modules/zeto_anon_enc_nullifier.ts +33 -1
  106. package/ignition/modules/zeto_anon_enc_nullifier_kyc.ts +2 -2
  107. package/ignition/modules/zeto_anon_enc_nullifier_non_repudiation.ts +2 -1
  108. package/ignition/modules/zeto_anon_nullifier.ts +30 -5
  109. package/ignition/modules/zeto_anon_nullifier_burnable.ts +52 -17
  110. package/ignition/modules/zeto_anon_nullifier_kyc.ts +27 -12
  111. package/ignition/modules/zeto_anon_nullifier_qurrency.ts +2 -1
  112. package/ignition/modules/zeto_nf_anon_nullifier.ts +16 -12
  113. package/package.json +4 -2
  114. package/scripts/deploy_cloneable.ts +19 -10
  115. package/scripts/deploy_upgradeable.ts +9 -5
  116. package/scripts/tokens/Zeto_Anon.ts +3 -3
  117. package/scripts/tokens/Zeto_AnonBurnable.ts +1 -1
  118. package/scripts/tokens/Zeto_AnonEnc.ts +12 -3
  119. package/scripts/tokens/Zeto_AnonEncNullifier.ts +7 -3
  120. package/scripts/tokens/Zeto_AnonEncNullifierKyc.ts +1 -1
  121. package/scripts/tokens/Zeto_AnonEncNullifierNonRepudiation.ts +3 -1
  122. package/scripts/tokens/Zeto_AnonNullifier.ts +3 -1
  123. package/scripts/tokens/Zeto_AnonNullifierBurnable.ts +3 -1
  124. package/scripts/tokens/Zeto_AnonNullifierKyc.ts +1 -1
  125. package/scripts/tokens/Zeto_AnonNullifierQurrency.ts +3 -1
  126. package/scripts/tokens/Zeto_NfAnon.ts +2 -2
  127. package/scripts/tokens/Zeto_NfAnonNullifier.ts +3 -2
  128. package/test/factory.ts +46 -73
  129. package/test/factory_upgradeable.ts +311 -0
  130. package/test/lib/anon_nullifier_helpers.ts +89 -0
  131. package/test/lib/anon_zeto_helpers.ts +76 -0
  132. package/test/lib/deploy.ts +3 -2
  133. package/test/lib/utils.ts +74 -35
  134. package/test/test/escrow1.ts +185 -58
  135. package/test/test/escrow2.ts +200 -107
  136. package/test/test/qurrency.ts +13 -33
  137. package/test/usdc-shielding.ts +39 -26
  138. package/test/utils.ts +144 -21
  139. package/test/zeto_anon.ts +956 -465
  140. package/test/zeto_anon_enc.ts +881 -142
  141. package/test/zeto_anon_enc_nullifier.ts +847 -38
  142. package/test/zeto_anon_enc_nullifier_kyc.ts +120 -181
  143. package/test/zeto_anon_enc_nullifier_non_repudiation.ts +77 -46
  144. package/test/zeto_anon_nullifier.ts +1212 -953
  145. package/test/zeto_anon_nullifier_kyc.ts +674 -655
  146. package/test/zeto_anon_nullifier_qurrency.ts +452 -306
  147. package/test/zeto_nf_anon.ts +737 -137
  148. package/test/zeto_nf_anon_nullifier.ts +876 -246
  149. package/contracts/lib/zeto_base.sol +0 -293
  150. package/contracts/lib/zeto_fungible_withdraw.sol +0 -132
  151. package/contracts/lib/zeto_fungible_withdraw_nullifier.sol +0 -144
  152. package/contracts/lib/zeto_nullifier.sol +0 -334
  153. package/contracts/zkDvP.sol_ +0 -273
  154. package/test/zkDvP.ts_ +0 -455
  155. /package/contracts/lib/{common.sol → common/common.sol} +0 -0
@@ -1,287 +1,34 @@
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
- */
1
+ // Copyright © 2025 Kaleido, Inc.
2
+ //
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 (the "License");
6
+ // you may not use this file except in compliance with the License.
7
+ // You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing, software
12
+ // distributed under the License is distributed on an "AS IS" BASIS,
13
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ // See the License for the specific language governing permissions and
15
+ // limitations under the License.
20
16
 
21
17
  pragma solidity >=0.7.0 <0.9.0;
22
18
 
23
- contract Groth16Verifier_AnonEncNullifier {
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 = 21767113377457482163774763180961397571908861454965904438481191641086468233901;
47
- uint256 constant IC0y = 4624875861526567202911495814020331377166312496504963505349049843648608533701;
48
-
49
- uint256 constant IC1x = 14860986793062837263857437470851021773286614977775025642944587642457106373388;
50
- uint256 constant IC1y = 6780359360136861569486151620398671261117351149004946989615152144109249397803;
51
-
52
- uint256 constant IC2x = 845983409689203792068684372342501483920956566184228820642615845345898680446;
53
- uint256 constant IC2y = 2264399858062580268203906466763966476019056089622366150777936394716933917456;
54
-
55
- uint256 constant IC3x = 20875590774495758723664898995248858136986986634838621272991805319889564743025;
56
- uint256 constant IC3y = 21322092515441561103719614913795933937703294036794980474550790297452413119032;
57
-
58
- uint256 constant IC4x = 19241982039611816000788771949737316356191928521635430701971460379905507503530;
59
- uint256 constant IC4y = 17418348432227363072982893999961998550912553041727999771911798781453917592631;
60
-
61
- uint256 constant IC5x = 21012908855212094839233072039264020664917264383796020919831824878452917527658;
62
- uint256 constant IC5y = 16763507679982019298101191460830972703239140291207409753764584934547856710197;
63
-
64
- uint256 constant IC6x = 11797940996879832419100924970381099799932007110119015028461836435572655782607;
65
- uint256 constant IC6y = 7342629377573433476209633696567454339786426287092270009487900518749996938677;
66
-
67
- uint256 constant IC7x = 5226667991218594386538121639762171607859554274771698182250369812846472765157;
68
- uint256 constant IC7y = 2643622664861522739176675092302307445064124162629982423740703951704445281744;
69
-
70
- uint256 constant IC8x = 19173808930079167374386453874770185211790885995046093093102688944488107276128;
71
- uint256 constant IC8y = 573907743114087661460713652375805152022924954398257734870306723679427156437;
72
-
73
- uint256 constant IC9x = 17296109958994013235070694309650997517098371526835385974517925258495812080570;
74
- uint256 constant IC9y = 2290956345454715673378395896923573589970135710846019254531160421318899454637;
75
-
76
- uint256 constant IC10x = 7980611979641535871350781948454499183632551034018083330962769611772384985554;
77
- uint256 constant IC10y = 10839341874304400265966117411599364749382683514447312223600777925830253594477;
78
-
79
- uint256 constant IC11x = 925674381192744625668098194172392649705674775222138450006550254068692584858;
80
- uint256 constant IC11y = 6540278959218686598083101327548060628532092094535168742584075267791246216974;
81
-
82
- uint256 constant IC12x = 15798050610002443084780214645264059516993617586829604603864730684970676647776;
83
- uint256 constant IC12y = 13329948258968477217196539760848048404209801267650319569672860890154306692690;
84
-
85
- uint256 constant IC13x = 8990856232251863542227189334160620655223502510154277406768438818018574959032;
86
- uint256 constant IC13y = 2937234133353045501107451354135532249703937455843003127763280966885612030375;
87
-
88
- uint256 constant IC14x = 1010902038545283042953412211699962477717211786665371564303886935044209553534;
89
- uint256 constant IC14y = 433526644315547962324934096626816096826295667205123833309665729101015038661;
90
-
91
- uint256 constant IC15x = 1467017793637684099973010225751266995695270652095719663995487312362716717018;
92
- uint256 constant IC15y = 17918994056503724120023893565716365544527444988647749161602683788209457176719;
93
-
94
- uint256 constant IC16x = 2924103576516766792403240615102674255252226232625806632563709128756163420079;
95
- uint256 constant IC16y = 11848577427320320784850393168109219367236172615919411876208678204818106696515;
96
-
97
- uint256 constant IC17x = 20416484247874595802672671706215547303999872307175711266743362488864148349000;
98
- uint256 constant IC17y = 19553969545734412812649583903220244511367307525188871900872552169885290158342;
99
-
100
- uint256 constant IC18x = 20953617420857830843754271872273927107747041835405498061334787891469941132470;
101
- uint256 constant IC18y = 3706281839732279609368724037031469687441244631269560192848450847915887465657;
102
-
103
-
104
- // Memory data
105
- uint16 constant pVk = 0;
106
- uint16 constant pPairing = 128;
107
-
108
- uint16 constant pLastMem = 896;
109
-
110
- function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[18] calldata _pubSignals) public view returns (bool) {
111
- assembly {
112
- function checkField(v) {
113
- if iszero(lt(v, r)) {
114
- mstore(0, 0)
115
- return(0, 0x20)
116
- }
117
- }
118
-
119
- // G1 function to multiply a G1 value(x,y) to value in an address
120
- function g1_mulAccC(pR, x, y, s) {
121
- let success
122
- let mIn := mload(0x40)
123
- mstore(mIn, x)
124
- mstore(add(mIn, 32), y)
125
- mstore(add(mIn, 64), s)
126
-
127
- success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
128
-
129
- if iszero(success) {
130
- mstore(0, 0)
131
- return(0, 0x20)
132
- }
133
-
134
- mstore(add(mIn, 64), mload(pR))
135
- mstore(add(mIn, 96), mload(add(pR, 32)))
136
-
137
- success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
138
-
139
- if iszero(success) {
140
- mstore(0, 0)
141
- return(0, 0x20)
142
- }
143
- }
144
-
145
- function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk {
146
- let _pPairing := add(pMem, pPairing)
147
- let _pVk := add(pMem, pVk)
148
-
149
- mstore(_pVk, IC0x)
150
- mstore(add(_pVk, 32), IC0y)
151
-
152
- // Compute the linear combination vk_x
153
-
154
- g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0)))
155
-
156
- g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
157
-
158
- g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
159
-
160
- g1_mulAccC(_pVk, IC4x, IC4y, calldataload(add(pubSignals, 96)))
161
-
162
- g1_mulAccC(_pVk, IC5x, IC5y, calldataload(add(pubSignals, 128)))
163
-
164
- g1_mulAccC(_pVk, IC6x, IC6y, calldataload(add(pubSignals, 160)))
165
-
166
- g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192)))
167
-
168
- g1_mulAccC(_pVk, IC8x, IC8y, calldataload(add(pubSignals, 224)))
169
-
170
- g1_mulAccC(_pVk, IC9x, IC9y, calldataload(add(pubSignals, 256)))
171
-
172
- g1_mulAccC(_pVk, IC10x, IC10y, calldataload(add(pubSignals, 288)))
173
-
174
- g1_mulAccC(_pVk, IC11x, IC11y, calldataload(add(pubSignals, 320)))
175
-
176
- g1_mulAccC(_pVk, IC12x, IC12y, calldataload(add(pubSignals, 352)))
177
-
178
- g1_mulAccC(_pVk, IC13x, IC13y, calldataload(add(pubSignals, 384)))
179
-
180
- g1_mulAccC(_pVk, IC14x, IC14y, calldataload(add(pubSignals, 416)))
181
-
182
- g1_mulAccC(_pVk, IC15x, IC15y, calldataload(add(pubSignals, 448)))
183
-
184
- g1_mulAccC(_pVk, IC16x, IC16y, calldataload(add(pubSignals, 480)))
185
-
186
- g1_mulAccC(_pVk, IC17x, IC17y, calldataload(add(pubSignals, 512)))
187
-
188
- g1_mulAccC(_pVk, IC18x, IC18y, calldataload(add(pubSignals, 544)))
189
-
190
-
191
- // -A
192
- mstore(_pPairing, calldataload(pA))
193
- mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
194
-
195
- // B
196
- mstore(add(_pPairing, 64), calldataload(pB))
197
- mstore(add(_pPairing, 96), calldataload(add(pB, 32)))
198
- mstore(add(_pPairing, 128), calldataload(add(pB, 64)))
199
- mstore(add(_pPairing, 160), calldataload(add(pB, 96)))
200
-
201
- // alpha1
202
- mstore(add(_pPairing, 192), alphax)
203
- mstore(add(_pPairing, 224), alphay)
204
-
205
- // beta2
206
- mstore(add(_pPairing, 256), betax1)
207
- mstore(add(_pPairing, 288), betax2)
208
- mstore(add(_pPairing, 320), betay1)
209
- mstore(add(_pPairing, 352), betay2)
210
-
211
- // vk_x
212
- mstore(add(_pPairing, 384), mload(add(pMem, pVk)))
213
- mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32))))
214
-
215
-
216
- // gamma2
217
- mstore(add(_pPairing, 448), gammax1)
218
- mstore(add(_pPairing, 480), gammax2)
219
- mstore(add(_pPairing, 512), gammay1)
220
- mstore(add(_pPairing, 544), gammay2)
221
-
222
- // C
223
- mstore(add(_pPairing, 576), calldataload(pC))
224
- mstore(add(_pPairing, 608), calldataload(add(pC, 32)))
225
-
226
- // delta2
227
- mstore(add(_pPairing, 640), deltax1)
228
- mstore(add(_pPairing, 672), deltax2)
229
- mstore(add(_pPairing, 704), deltay1)
230
- mstore(add(_pPairing, 736), deltay2)
231
-
232
-
233
- let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
234
-
235
- isOk := and(success, mload(_pPairing))
236
- }
237
-
238
- let pMem := mload(0x40)
239
- mstore(0x40, add(pMem, pLastMem))
240
-
241
- // Validate that all evaluations ∈ F
242
-
243
- checkField(calldataload(add(_pubSignals, 0)))
244
-
245
- checkField(calldataload(add(_pubSignals, 32)))
246
-
247
- checkField(calldataload(add(_pubSignals, 64)))
248
-
249
- checkField(calldataload(add(_pubSignals, 96)))
250
-
251
- checkField(calldataload(add(_pubSignals, 128)))
252
-
253
- checkField(calldataload(add(_pubSignals, 160)))
254
-
255
- checkField(calldataload(add(_pubSignals, 192)))
256
-
257
- checkField(calldataload(add(_pubSignals, 224)))
258
-
259
- checkField(calldataload(add(_pubSignals, 256)))
260
-
261
- checkField(calldataload(add(_pubSignals, 288)))
262
-
263
- checkField(calldataload(add(_pubSignals, 320)))
264
-
265
- checkField(calldataload(add(_pubSignals, 352)))
266
-
267
- checkField(calldataload(add(_pubSignals, 384)))
268
-
269
- checkField(calldataload(add(_pubSignals, 416)))
270
-
271
- checkField(calldataload(add(_pubSignals, 448)))
272
-
273
- checkField(calldataload(add(_pubSignals, 480)))
274
-
275
- checkField(calldataload(add(_pubSignals, 512)))
276
-
277
- checkField(calldataload(add(_pubSignals, 544)))
278
-
279
-
280
- // Validate all evaluations
281
- let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
282
-
283
- mstore(0, isValid)
284
- return(0, 0x20)
285
- }
286
- }
287
- }
19
+ import {Verifier_AnonEncNullifier} from "./impl/anon_enc_nullifier.sol";
20
+
21
+ contract Groth16Verifier_AnonEncNullifier is Verifier_AnonEncNullifier {
22
+ function verify(
23
+ uint[2] calldata _pA,
24
+ uint[2][2] calldata _pB,
25
+ uint[2] calldata _pC,
26
+ uint[] calldata _pubSignals
27
+ ) public view returns (bool) {
28
+ uint256[18] memory fixedSizeInputs;
29
+ for (uint256 i = 0; i < fixedSizeInputs.length; i++) {
30
+ fixedSizeInputs[i] = _pubSignals[i];
31
+ }
32
+ return this.verifyProof(_pA, _pB, _pC, fixedSizeInputs);
33
+ }
34
+ }