@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,217 +1,36 @@
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_AnonNullifierKycTransfer {
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 = 4549255854730728979068045147826494135688297252583383060843842296705895492978;
47
- uint256 constant IC0y = 5950970323653353113740267223097183547451063574376546024149863590759652058488;
48
-
49
- uint256 constant IC1x = 1216073448663996885271432419027841106055434472971561665165335238062653822316;
50
- uint256 constant IC1y = 5097558434483111811746720335754493980758046673865340798005109731076493822092;
51
-
52
- uint256 constant IC2x = 11161664165685458227890392607023596630662854996855616216929683515288525643261;
53
- uint256 constant IC2y = 12818956025711134634246546712440119681905145689756714720889316358763299716670;
54
-
55
- uint256 constant IC3x = 9365147676333024284193510374200233681101801733129915318628858200430878767972;
56
- uint256 constant IC3y = 16602542985321581865161591791610629735092802111155748538031045719192964144533;
57
-
58
- uint256 constant IC4x = 16628303690015057161260898115672715952728211813184122219719600578319362166707;
59
- uint256 constant IC4y = 15728053840296638802851558372415064634368090476197617381470156332889352222403;
60
-
61
- uint256 constant IC5x = 5827873543537045343412383010600634430953834092125113195251309483077699447403;
62
- uint256 constant IC5y = 10857871525251638374522087235240657063634455578539572588195509683601405770706;
63
-
64
- uint256 constant IC6x = 6904548272880268591909423473706195905482887793913653919663823478756560783089;
65
- uint256 constant IC6y = 13063380749905117216780308403936319461263137579341895411135333490405118421388;
66
-
67
- uint256 constant IC7x = 14792454403924655648675695084766983654532792668337095643557509432994258770907;
68
- uint256 constant IC7y = 275832895488262903192405898395553290304405685441693387518881548143112407836;
69
-
70
- uint256 constant IC8x = 9609823634861781908325095271708251605778434197921847173219811698057550155044;
71
- uint256 constant IC8y = 3132713041953533394988012935482842223032660540368789530274800749083525578584;
72
-
73
-
74
- // Memory data
75
- uint16 constant pVk = 0;
76
- uint16 constant pPairing = 128;
77
-
78
- uint16 constant pLastMem = 896;
79
-
80
- function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[8] calldata _pubSignals) public view returns (bool) {
81
- assembly {
82
- function checkField(v) {
83
- if iszero(lt(v, r)) {
84
- mstore(0, 0)
85
- return(0, 0x20)
86
- }
87
- }
88
-
89
- // G1 function to multiply a G1 value(x,y) to value in an address
90
- function g1_mulAccC(pR, x, y, s) {
91
- let success
92
- let mIn := mload(0x40)
93
- mstore(mIn, x)
94
- mstore(add(mIn, 32), y)
95
- mstore(add(mIn, 64), s)
96
-
97
- success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
98
-
99
- if iszero(success) {
100
- mstore(0, 0)
101
- return(0, 0x20)
102
- }
103
-
104
- mstore(add(mIn, 64), mload(pR))
105
- mstore(add(mIn, 96), mload(add(pR, 32)))
106
-
107
- success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
108
-
109
- if iszero(success) {
110
- mstore(0, 0)
111
- return(0, 0x20)
112
- }
113
- }
114
-
115
- function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk {
116
- let _pPairing := add(pMem, pPairing)
117
- let _pVk := add(pMem, pVk)
118
-
119
- mstore(_pVk, IC0x)
120
- mstore(add(_pVk, 32), IC0y)
121
-
122
- // Compute the linear combination vk_x
123
-
124
- g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0)))
125
-
126
- g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
127
-
128
- g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
129
-
130
- g1_mulAccC(_pVk, IC4x, IC4y, calldataload(add(pubSignals, 96)))
131
-
132
- g1_mulAccC(_pVk, IC5x, IC5y, calldataload(add(pubSignals, 128)))
133
-
134
- g1_mulAccC(_pVk, IC6x, IC6y, calldataload(add(pubSignals, 160)))
135
-
136
- g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192)))
137
-
138
- g1_mulAccC(_pVk, IC8x, IC8y, calldataload(add(pubSignals, 224)))
139
-
140
-
141
- // -A
142
- mstore(_pPairing, calldataload(pA))
143
- mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
144
-
145
- // B
146
- mstore(add(_pPairing, 64), calldataload(pB))
147
- mstore(add(_pPairing, 96), calldataload(add(pB, 32)))
148
- mstore(add(_pPairing, 128), calldataload(add(pB, 64)))
149
- mstore(add(_pPairing, 160), calldataload(add(pB, 96)))
150
-
151
- // alpha1
152
- mstore(add(_pPairing, 192), alphax)
153
- mstore(add(_pPairing, 224), alphay)
154
-
155
- // beta2
156
- mstore(add(_pPairing, 256), betax1)
157
- mstore(add(_pPairing, 288), betax2)
158
- mstore(add(_pPairing, 320), betay1)
159
- mstore(add(_pPairing, 352), betay2)
160
-
161
- // vk_x
162
- mstore(add(_pPairing, 384), mload(add(pMem, pVk)))
163
- mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32))))
164
-
165
-
166
- // gamma2
167
- mstore(add(_pPairing, 448), gammax1)
168
- mstore(add(_pPairing, 480), gammax2)
169
- mstore(add(_pPairing, 512), gammay1)
170
- mstore(add(_pPairing, 544), gammay2)
171
-
172
- // C
173
- mstore(add(_pPairing, 576), calldataload(pC))
174
- mstore(add(_pPairing, 608), calldataload(add(pC, 32)))
175
-
176
- // delta2
177
- mstore(add(_pPairing, 640), deltax1)
178
- mstore(add(_pPairing, 672), deltax2)
179
- mstore(add(_pPairing, 704), deltay1)
180
- mstore(add(_pPairing, 736), deltay2)
181
-
182
-
183
- let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
184
-
185
- isOk := and(success, mload(_pPairing))
186
- }
187
-
188
- let pMem := mload(0x40)
189
- mstore(0x40, add(pMem, pLastMem))
190
-
191
- // Validate that all evaluations ∈ F
192
-
193
- checkField(calldataload(add(_pubSignals, 0)))
194
-
195
- checkField(calldataload(add(_pubSignals, 32)))
196
-
197
- checkField(calldataload(add(_pubSignals, 64)))
198
-
199
- checkField(calldataload(add(_pubSignals, 96)))
200
-
201
- checkField(calldataload(add(_pubSignals, 128)))
202
-
203
- checkField(calldataload(add(_pubSignals, 160)))
204
-
205
- checkField(calldataload(add(_pubSignals, 192)))
206
-
207
- checkField(calldataload(add(_pubSignals, 224)))
208
-
209
-
210
- // Validate all evaluations
211
- let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
212
-
213
- mstore(0, isValid)
214
- return(0, 0x20)
215
- }
216
- }
217
- }
19
+ import {Verifier_AnonNullifierKycTransfer} from "./impl/anon_nullifier_kyc_transfer.sol";
20
+
21
+ contract Groth16Verifier_AnonNullifierKycTransfer is
22
+ Verifier_AnonNullifierKycTransfer
23
+ {
24
+ function verify(
25
+ uint[2] calldata _pA,
26
+ uint[2][2] calldata _pB,
27
+ uint[2] calldata _pC,
28
+ uint[] calldata _pubSignals
29
+ ) public view returns (bool) {
30
+ uint256[8] memory fixedSizeInputs;
31
+ for (uint256 i = 0; i < fixedSizeInputs.length; i++) {
32
+ fixedSizeInputs[i] = _pubSignals[i];
33
+ }
34
+ return this.verifyProof(_pA, _pB, _pC, fixedSizeInputs);
35
+ }
36
+ }
@@ -1,224 +1,36 @@
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_AnonNullifierKycTransferLocked {
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 = 4549255854730728979068045147826494135688297252583383060843842296705895492978;
47
- uint256 constant IC0y = 5950970323653353113740267223097183547451063574376546024149863590759652058488;
48
-
49
- uint256 constant IC1x = 1216073448663996885271432419027841106055434472971561665165335238062653822316;
50
- uint256 constant IC1y = 5097558434483111811746720335754493980758046673865340798005109731076493822092;
51
-
52
- uint256 constant IC2x = 11161664165685458227890392607023596630662854996855616216929683515288525643261;
53
- uint256 constant IC2y = 12818956025711134634246546712440119681905145689756714720889316358763299716670;
54
-
55
- uint256 constant IC3x = 18953400531314048493020249666915884736194198558848991201724079983703815588941;
56
- uint256 constant IC3y = 13699191758758035746733801303773823863589848011566156471658385360695236966394;
57
-
58
- uint256 constant IC4x = 6418340491795971921392115660810008144220633855594784047024627824300258762503;
59
- uint256 constant IC4y = 331206681118086868666335692518221964875102632478886860969461713448972106730;
60
-
61
- uint256 constant IC5x = 20672826781381085929236676912315916823659231399175782091852650610024412774769;
62
- uint256 constant IC5y = 11005715100892641133661679250179409252147733448250729630291805759444701807471;
63
-
64
- uint256 constant IC6x = 12231940204046029565793569026881079629242556494447978554412435777385899724966;
65
- uint256 constant IC6y = 3022258914215080208953007370687180295593086983336375430220334804021677602519;
66
-
67
- uint256 constant IC7x = 2730676615629181794195823324572752660852961858858579583326943949762787485542;
68
- uint256 constant IC7y = 19195486438582872786798796988852373517285255929228549822615489262799978113088;
69
-
70
- uint256 constant IC8x = 20579458023158866087289023203244829165084026526103516895694907053440656858473;
71
- uint256 constant IC8y = 3021614608224014561606228442635508559916615305041679215398457772032721217921;
72
-
73
- uint256 constant IC9x = 19700709081187424389075413367891493951275133113931731320975747028787203904612;
74
- uint256 constant IC9y = 14877838899466508832438353194361674038017333564191473092717528104566401199120;
75
-
76
-
77
- // Memory data
78
- uint16 constant pVk = 0;
79
- uint16 constant pPairing = 128;
80
-
81
- uint16 constant pLastMem = 896;
82
-
83
- function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[9] calldata _pubSignals) public view returns (bool) {
84
- assembly {
85
- function checkField(v) {
86
- if iszero(lt(v, r)) {
87
- mstore(0, 0)
88
- return(0, 0x20)
89
- }
90
- }
91
-
92
- // G1 function to multiply a G1 value(x,y) to value in an address
93
- function g1_mulAccC(pR, x, y, s) {
94
- let success
95
- let mIn := mload(0x40)
96
- mstore(mIn, x)
97
- mstore(add(mIn, 32), y)
98
- mstore(add(mIn, 64), s)
99
-
100
- success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
101
-
102
- if iszero(success) {
103
- mstore(0, 0)
104
- return(0, 0x20)
105
- }
106
-
107
- mstore(add(mIn, 64), mload(pR))
108
- mstore(add(mIn, 96), mload(add(pR, 32)))
109
-
110
- success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
111
-
112
- if iszero(success) {
113
- mstore(0, 0)
114
- return(0, 0x20)
115
- }
116
- }
117
-
118
- function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk {
119
- let _pPairing := add(pMem, pPairing)
120
- let _pVk := add(pMem, pVk)
121
-
122
- mstore(_pVk, IC0x)
123
- mstore(add(_pVk, 32), IC0y)
124
-
125
- // Compute the linear combination vk_x
126
-
127
- g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0)))
128
-
129
- g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
130
-
131
- g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
132
-
133
- g1_mulAccC(_pVk, IC4x, IC4y, calldataload(add(pubSignals, 96)))
134
-
135
- g1_mulAccC(_pVk, IC5x, IC5y, calldataload(add(pubSignals, 128)))
136
-
137
- g1_mulAccC(_pVk, IC6x, IC6y, calldataload(add(pubSignals, 160)))
138
-
139
- g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192)))
140
-
141
- g1_mulAccC(_pVk, IC8x, IC8y, calldataload(add(pubSignals, 224)))
142
-
143
- g1_mulAccC(_pVk, IC9x, IC9y, calldataload(add(pubSignals, 256)))
144
-
145
-
146
- // -A
147
- mstore(_pPairing, calldataload(pA))
148
- mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
149
-
150
- // B
151
- mstore(add(_pPairing, 64), calldataload(pB))
152
- mstore(add(_pPairing, 96), calldataload(add(pB, 32)))
153
- mstore(add(_pPairing, 128), calldataload(add(pB, 64)))
154
- mstore(add(_pPairing, 160), calldataload(add(pB, 96)))
155
-
156
- // alpha1
157
- mstore(add(_pPairing, 192), alphax)
158
- mstore(add(_pPairing, 224), alphay)
159
-
160
- // beta2
161
- mstore(add(_pPairing, 256), betax1)
162
- mstore(add(_pPairing, 288), betax2)
163
- mstore(add(_pPairing, 320), betay1)
164
- mstore(add(_pPairing, 352), betay2)
165
-
166
- // vk_x
167
- mstore(add(_pPairing, 384), mload(add(pMem, pVk)))
168
- mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32))))
169
-
170
-
171
- // gamma2
172
- mstore(add(_pPairing, 448), gammax1)
173
- mstore(add(_pPairing, 480), gammax2)
174
- mstore(add(_pPairing, 512), gammay1)
175
- mstore(add(_pPairing, 544), gammay2)
176
-
177
- // C
178
- mstore(add(_pPairing, 576), calldataload(pC))
179
- mstore(add(_pPairing, 608), calldataload(add(pC, 32)))
180
-
181
- // delta2
182
- mstore(add(_pPairing, 640), deltax1)
183
- mstore(add(_pPairing, 672), deltax2)
184
- mstore(add(_pPairing, 704), deltay1)
185
- mstore(add(_pPairing, 736), deltay2)
186
-
187
-
188
- let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
189
-
190
- isOk := and(success, mload(_pPairing))
191
- }
192
-
193
- let pMem := mload(0x40)
194
- mstore(0x40, add(pMem, pLastMem))
195
-
196
- // Validate that all evaluations ∈ F
197
-
198
- checkField(calldataload(add(_pubSignals, 0)))
199
-
200
- checkField(calldataload(add(_pubSignals, 32)))
201
-
202
- checkField(calldataload(add(_pubSignals, 64)))
203
-
204
- checkField(calldataload(add(_pubSignals, 96)))
205
-
206
- checkField(calldataload(add(_pubSignals, 128)))
207
-
208
- checkField(calldataload(add(_pubSignals, 160)))
209
-
210
- checkField(calldataload(add(_pubSignals, 192)))
211
-
212
- checkField(calldataload(add(_pubSignals, 224)))
213
-
214
- checkField(calldataload(add(_pubSignals, 256)))
215
-
216
-
217
- // Validate all evaluations
218
- let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
219
-
220
- mstore(0, isValid)
221
- return(0, 0x20)
222
- }
223
- }
224
- }
19
+ import {Verifier_AnonNullifierKycTransferLocked} from "./impl/anon_nullifier_kyc_transferLocked.sol";
20
+
21
+ contract Groth16Verifier_AnonNullifierKycTransferLocked is
22
+ Verifier_AnonNullifierKycTransferLocked
23
+ {
24
+ function verify(
25
+ uint[2] calldata _pA,
26
+ uint[2][2] calldata _pB,
27
+ uint[2] calldata _pC,
28
+ uint[] calldata _pubSignals
29
+ ) public view returns (bool) {
30
+ uint256[5] memory fixedSizeInputs;
31
+ for (uint256 i = 0; i < fixedSizeInputs.length; i++) {
32
+ fixedSizeInputs[i] = _pubSignals[i];
33
+ }
34
+ return this.verifyProof(_pA, _pB, _pC, fixedSizeInputs);
35
+ }
36
+ }