@lfdecentralizedtrust/zeto-contracts 0.2.2 → 0.5.1

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 (164) hide show
  1. package/README.md +76 -162
  2. package/config/eip170.ts +30 -0
  3. package/contracts/factory.sol +30 -34
  4. package/contracts/factory_upgradeable.sol +11 -7
  5. package/contracts/lib/common/util.sol +40 -0
  6. package/contracts/lib/interfaces/ILockableCapability.sol +318 -0
  7. package/contracts/lib/interfaces/{izeto.sol → IZeto.sol} +13 -1
  8. package/contracts/lib/interfaces/{izeto_initializable.sol → IZetoInitializable.sol} +14 -12
  9. package/contracts/lib/interfaces/{izeto_kyc.sol → IZetoKyc.sol} +3 -3
  10. package/contracts/lib/interfaces/IZetoLockHooks.sol +42 -0
  11. package/contracts/lib/interfaces/IZetoLockableCapability.sol +237 -0
  12. package/contracts/lib/interfaces/IZetoStorage.sol +106 -0
  13. package/contracts/lib/interfaces/{izeto_lockable.sol → IZetoVerifier.sol} +8 -21
  14. package/contracts/lib/registry.sol +74 -26
  15. package/contracts/lib/storage/base.sol +210 -0
  16. package/contracts/lib/storage/nullifier.sol +166 -0
  17. package/contracts/lib/zeto_common.sol +277 -28
  18. package/contracts/lib/zeto_fungible.sol +443 -33
  19. package/contracts/lib/zeto_fungible_base.sol +69 -0
  20. package/contracts/lib/zeto_fungible_burn.sol +83 -53
  21. package/contracts/lib/zeto_fungible_burn_nullifier.sol +115 -72
  22. package/contracts/lib/zeto_fungible_nullifier.sol +167 -0
  23. package/contracts/lib/zeto_lockable.sol +219 -0
  24. package/contracts/lib/zeto_lockable_lib.sol +460 -0
  25. package/contracts/lib/zeto_lockable_storage.sol +43 -0
  26. package/contracts/lib/zeto_non_fungible.sol +228 -0
  27. package/contracts/lib/zeto_non_fungible_base.sol +61 -0
  28. package/contracts/lib/zeto_non_fungible_nullifier.sol +61 -0
  29. package/contracts/test/escrow1.sol +90 -34
  30. package/contracts/test/escrow2.sol +64 -29
  31. package/contracts/test/qurrency.sol +10 -2
  32. package/contracts/test/smt.sol +6 -1
  33. package/contracts/test/tendecimals.sol +14 -12
  34. package/contracts/verifiers/impl/anon.sol +189 -0
  35. package/contracts/verifiers/impl/anon_batch.sol +301 -0
  36. package/contracts/verifiers/impl/anon_enc.sol +266 -0
  37. package/contracts/verifiers/impl/anon_enc_batch.sol +602 -0
  38. package/contracts/verifiers/impl/anon_enc_nullifier.sol +287 -0
  39. package/contracts/verifiers/impl/anon_enc_nullifier_batch.sol +679 -0
  40. package/contracts/verifiers/impl/anon_enc_nullifier_kyc.sol +294 -0
  41. package/contracts/verifiers/impl/anon_enc_nullifier_kyc_batch.sol +686 -0
  42. package/contracts/verifiers/impl/anon_enc_nullifier_non_repudiation.sol +413 -0
  43. package/contracts/verifiers/impl/anon_enc_nullifier_non_repudiation_batch.sol +1141 -0
  44. package/contracts/verifiers/impl/anon_nullifier_kyc_transfer.sol +217 -0
  45. package/contracts/verifiers/impl/anon_nullifier_kyc_transferLocked.sol +196 -0
  46. package/contracts/verifiers/impl/anon_nullifier_kyc_transferLocked_batch.sol +308 -0
  47. package/contracts/verifiers/impl/anon_nullifier_kyc_transfer_batch.sol +385 -0
  48. package/contracts/verifiers/impl/anon_nullifier_qurrency_transfer.sol +497 -0
  49. package/contracts/verifiers/impl/anon_nullifier_qurrency_transfer_batch.sol +1001 -0
  50. package/contracts/verifiers/{verifier_anon_nullifier_transferLocked.sol → impl/anon_nullifier_transfer.sol} +12 -19
  51. package/contracts/verifiers/{verifier_anon_nullifier_transferLocked_batch.sol → impl/anon_nullifier_transfer_batch.sol} +44 -51
  52. package/contracts/verifiers/impl/burn.sol +182 -0
  53. package/contracts/verifiers/impl/burn_batch.sol +238 -0
  54. package/contracts/verifiers/impl/burn_nullifier.sol +203 -0
  55. package/contracts/verifiers/impl/burn_nullifier_batch.sol +315 -0
  56. package/contracts/verifiers/impl/deposit.sol +182 -0
  57. package/contracts/verifiers/impl/deposit_kyc.sol +189 -0
  58. package/contracts/verifiers/impl/nf_anon.sol +175 -0
  59. package/contracts/verifiers/{verifier_nf_anon_nullifier_transferLocked.sol → impl/nf_anon_nullifier_transfer.sol} +6 -13
  60. package/contracts/verifiers/impl/withdraw.sol +189 -0
  61. package/contracts/verifiers/impl/withdraw_batch.sol +245 -0
  62. package/contracts/verifiers/impl/withdraw_nullifier.sol +210 -0
  63. package/contracts/verifiers/impl/withdraw_nullifier_batch.sol +322 -0
  64. package/contracts/verifiers/verifier_anon.sol +31 -186
  65. package/contracts/verifiers/verifier_anon_batch.sol +31 -298
  66. package/contracts/verifiers/verifier_anon_enc.sol +31 -263
  67. package/contracts/verifiers/verifier_anon_enc_batch.sol +31 -599
  68. package/contracts/verifiers/verifier_anon_enc_nullifier.sol +31 -284
  69. package/contracts/verifiers/verifier_anon_enc_nullifier_batch.sol +33 -676
  70. package/contracts/verifiers/verifier_anon_enc_nullifier_kyc.sol +31 -291
  71. package/contracts/verifiers/verifier_anon_enc_nullifier_kyc_batch.sol +33 -683
  72. package/contracts/verifiers/verifier_anon_enc_nullifier_non_repudiation.sol +33 -410
  73. package/contracts/verifiers/verifier_anon_enc_nullifier_non_repudiation_batch.sol +33 -1138
  74. package/contracts/verifiers/verifier_anon_nullifier_kyc_transfer.sol +33 -214
  75. package/contracts/verifiers/verifier_anon_nullifier_kyc_transferLocked.sol +33 -221
  76. package/contracts/verifiers/verifier_anon_nullifier_kyc_transferLocked_batch.sol +33 -389
  77. package/contracts/verifiers/verifier_anon_nullifier_kyc_transfer_batch.sol +33 -382
  78. package/contracts/verifiers/verifier_anon_nullifier_qurrency_transfer.sol +33 -221
  79. package/contracts/verifiers/verifier_anon_nullifier_qurrency_transfer_batch.sol +33 -389
  80. package/contracts/verifiers/verifier_anon_nullifier_transfer.sol +33 -207
  81. package/contracts/verifiers/verifier_anon_nullifier_transfer_batch.sol +33 -375
  82. package/contracts/verifiers/verifier_burn.sol +31 -179
  83. package/contracts/verifiers/verifier_burn_batch.sol +31 -235
  84. package/contracts/verifiers/verifier_burn_nullifier.sol +31 -200
  85. package/contracts/verifiers/verifier_burn_nullifier_batch.sol +31 -312
  86. package/contracts/verifiers/verifier_deposit.sol +31 -179
  87. package/contracts/verifiers/verifier_deposit_kyc.sol +34 -0
  88. package/contracts/verifiers/verifier_nf_anon.sol +31 -172
  89. package/contracts/verifiers/verifier_nf_anon_nullifier_transfer.sol +33 -179
  90. package/contracts/verifiers/verifier_withdraw.sol +31 -186
  91. package/contracts/verifiers/verifier_withdraw_batch.sol +31 -242
  92. package/contracts/verifiers/verifier_withdraw_nullifier.sol +31 -207
  93. package/contracts/verifiers/verifier_withdraw_nullifier_batch.sol +33 -319
  94. package/contracts/zeto_anon.sol +77 -231
  95. package/contracts/zeto_anon_burnable.sol +56 -12
  96. package/contracts/zeto_anon_enc.sol +93 -190
  97. package/contracts/zeto_anon_enc_nullifier.sol +249 -195
  98. package/contracts/zeto_anon_enc_nullifier_kyc.sol +51 -232
  99. package/contracts/zeto_anon_enc_nullifier_non_repudiation.sol +231 -238
  100. package/contracts/zeto_anon_nullifier.sol +164 -298
  101. package/contracts/zeto_anon_nullifier_burnable.sol +68 -18
  102. package/contracts/zeto_anon_nullifier_kyc.sol +40 -345
  103. package/contracts/zeto_anon_nullifier_qurrency.sol +217 -361
  104. package/contracts/zeto_nf_anon.sol +55 -130
  105. package/contracts/zeto_nf_anon_nullifier.sol +90 -152
  106. package/hardhat.config.ts +18 -3
  107. package/ignition/modules/lib/deps.ts +13 -0
  108. package/ignition/modules/test/tendecimals.ts +7 -1
  109. package/ignition/modules/zeto_anon.ts +3 -0
  110. package/ignition/modules/zeto_anon_burnable.ts +11 -7
  111. package/ignition/modules/zeto_anon_enc.ts +3 -0
  112. package/ignition/modules/zeto_anon_enc_nullifier.ts +34 -0
  113. package/ignition/modules/zeto_anon_enc_nullifier_kyc.ts +5 -2
  114. package/ignition/modules/zeto_anon_enc_nullifier_non_repudiation.ts +3 -0
  115. package/ignition/modules/zeto_anon_nullifier.ts +31 -4
  116. package/ignition/modules/zeto_anon_nullifier_burnable.ts +53 -16
  117. package/ignition/modules/zeto_anon_nullifier_kyc.ts +30 -12
  118. package/ignition/modules/zeto_anon_nullifier_qurrency.ts +3 -0
  119. package/ignition/modules/zeto_nf_anon.ts +3 -1
  120. package/ignition/modules/zeto_nf_anon_nullifier.ts +17 -12
  121. package/package.json +7 -3
  122. package/scripts/deploy_cloneable.ts +19 -10
  123. package/scripts/deploy_upgradeable.ts +9 -5
  124. package/scripts/lib/zeto_libraries.ts +47 -0
  125. package/scripts/tokens/Zeto_Anon.ts +6 -3
  126. package/scripts/tokens/Zeto_AnonBurnable.ts +4 -1
  127. package/scripts/tokens/Zeto_AnonEnc.ts +15 -3
  128. package/scripts/tokens/Zeto_AnonEncNullifier.ts +11 -8
  129. package/scripts/tokens/Zeto_AnonEncNullifierKyc.ts +7 -6
  130. package/scripts/tokens/Zeto_AnonEncNullifierNonRepudiation.ts +7 -6
  131. package/scripts/tokens/Zeto_AnonNullifier.ts +7 -6
  132. package/scripts/tokens/Zeto_AnonNullifierBurnable.ts +7 -6
  133. package/scripts/tokens/Zeto_AnonNullifierKyc.ts +7 -6
  134. package/scripts/tokens/Zeto_AnonNullifierQurrency.ts +7 -8
  135. package/scripts/tokens/Zeto_NfAnon.ts +5 -3
  136. package/scripts/tokens/Zeto_NfAnonNullifier.ts +7 -7
  137. package/test/factory.ts +55 -73
  138. package/test/lib/anon_nullifier_helpers.ts +89 -0
  139. package/test/lib/anon_zeto_helpers.ts +76 -0
  140. package/test/lib/deploy.ts +5 -2
  141. package/test/lib/eip170.ts +23 -0
  142. package/test/lib/utils.ts +74 -35
  143. package/test/test/escrow1.ts +185 -58
  144. package/test/test/escrow2.ts +200 -107
  145. package/test/test/qurrency.ts +13 -33
  146. package/test/usdc-shielding.ts +39 -27
  147. package/test/utils.ts +144 -21
  148. package/test/zeto_anon.ts +956 -465
  149. package/test/zeto_anon_enc.ts +881 -143
  150. package/test/zeto_anon_enc_nullifier.ts +850 -39
  151. package/test/zeto_anon_enc_nullifier_kyc.ts +123 -182
  152. package/test/zeto_anon_enc_nullifier_non_repudiation.ts +80 -47
  153. package/test/zeto_anon_nullifier.ts +1212 -954
  154. package/test/zeto_anon_nullifier_kyc.ts +677 -656
  155. package/test/zeto_anon_nullifier_qurrency.ts +455 -307
  156. package/test/zeto_nf_anon.ts +737 -138
  157. package/test/zeto_nf_anon_nullifier.ts +876 -247
  158. package/contracts/lib/zeto_base.sol +0 -293
  159. package/contracts/lib/zeto_fungible_withdraw.sol +0 -132
  160. package/contracts/lib/zeto_fungible_withdraw_nullifier.sol +0 -144
  161. package/contracts/lib/zeto_nullifier.sol +0 -340
  162. package/contracts/zkDvP.sol_ +0 -273
  163. package/test/zkDvP.ts_ +0 -455
  164. /package/contracts/lib/{common.sol → common/common.sol} +0 -0
@@ -1,392 +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_AnonNullifierQurrencyTransferBatch {
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 = 17053846928344350998802493580738087638595330724782781948435593299499494607525;
47
- uint256 constant IC0y = 11965101847161311578209229394992329677895998609610483438614848062187538581110;
48
-
49
- uint256 constant IC1x = 1416194646929535355694961892995828689863356211965628527713606059894446238038;
50
- uint256 constant IC1y = 456044554490155452010102389189051360820956479208305795526734941401238411466;
51
-
52
- uint256 constant IC2x = 8087066964925552101460451401729574162674687512622755070888846220371572721704;
53
- uint256 constant IC2y = 15516298309359181754580176158703498279338476003035208475645654315864718870185;
54
-
55
- uint256 constant IC3x = 14221226657510344054981374137585092978226039660356979765704049882963729283380;
56
- uint256 constant IC3y = 10826686834380743127420058120136775573660372530261114276689337190657020313482;
57
-
58
- uint256 constant IC4x = 14439720623476024065768519458429320832855317504582578222039304640840634004987;
59
- uint256 constant IC4y = 2506469716311245496110064301350397589647219280839456013860637025786218716281;
60
-
61
- uint256 constant IC5x = 2964373650465844939517216113136466716939318358858344677893008536857129305097;
62
- uint256 constant IC5y = 13686558959063950222463718507188705519344855739984468357073269562983130305536;
63
-
64
- uint256 constant IC6x = 6285332050840516953606369049058563419719888604452221160574092159448223154749;
65
- uint256 constant IC6y = 7324544316662822664953692845820960361177945724006937850477874814951454665939;
66
-
67
- uint256 constant IC7x = 10973328992454293464881854246539676769078232367342610017014599255215513204427;
68
- uint256 constant IC7y = 2637623550748559276689766007212456337881393074082218754280977251337573372493;
69
-
70
- uint256 constant IC8x = 12545399138035900164985864294759207402086474720904151642580607935367772170956;
71
- uint256 constant IC8y = 14825351401529746245331316381645932327893986450085684914372926733548796504544;
72
-
73
- uint256 constant IC9x = 10825637261529123822006395152254800939166390443991243847598467737093888038475;
74
- uint256 constant IC9y = 13925843112575707179357038463822315968135818477725919048257517656905830231940;
75
-
76
- uint256 constant IC10x = 10709399669843897804820408705872200687229687444941121043068093969751437714239;
77
- uint256 constant IC10y = 12945565768336613640250021946893568789525339792326281028287433582934267853691;
78
-
79
- uint256 constant IC11x = 15478768072736778467135646669659753456805133374812265361207351070980706340384;
80
- uint256 constant IC11y = 757839902315670936992660121748072013381281184371933739957693841120676378002;
81
-
82
- uint256 constant IC12x = 4554328073414005090653798625419395616893283931820566192326003016260571360052;
83
- uint256 constant IC12y = 1189389969203651564424575651852817126244952250829977490103548995493474299068;
84
-
85
- uint256 constant IC13x = 335829615964528144092757207789952008304371933206676563321102340898251319007;
86
- uint256 constant IC13y = 7731623954002786012215407813203682032586372955885834065664656306132436365997;
87
-
88
- uint256 constant IC14x = 6091392840361353734767778321454651042379507055073555682363886625925248203953;
89
- uint256 constant IC14y = 19306885946682325940783901113266304521196152351265261204343763298239638114306;
90
-
91
- uint256 constant IC15x = 11783656308232177277179388577866161511078872590959241741029409831643637632222;
92
- uint256 constant IC15y = 12526532078490070951167473821139535551490355136135051918688670323190956618291;
93
-
94
- uint256 constant IC16x = 6774458908312308966332504282524318745453711933969918461887753636628499023808;
95
- uint256 constant IC16y = 5910580788766187271180059836424966363377676141947616160646236766473269226599;
96
-
97
- uint256 constant IC17x = 10567369672791205263003124170963246864801473350246391064941849014254786273735;
98
- uint256 constant IC17y = 8525774187896720446713518183468602490041224033557699960779335634243943211110;
99
-
100
- uint256 constant IC18x = 13736933573651228496910079418144261258524074264645273086746502671564881732932;
101
- uint256 constant IC18y = 17907482215882844837274299573884025729157175374684311033592383852522475284068;
102
-
103
- uint256 constant IC19x = 503946258479389959434810413589495651112746495188788310664557844970060278337;
104
- uint256 constant IC19y = 4952976642403343892721288326300163714557818354830166037263932519311901177528;
105
-
106
- uint256 constant IC20x = 14246884670603723776095340731061770886790480641143757738376275175974985675095;
107
- uint256 constant IC20y = 16825920812472170640525350082442236220755804552262442967471744311463529021677;
108
-
109
- uint256 constant IC21x = 9378993931629170226110616467888292821413775486786627591375263726877920778415;
110
- uint256 constant IC21y = 10528494380808624817716159611589774734053547246328184472636315616238844751256;
111
-
112
- uint256 constant IC22x = 369944225205660230371070237824000305195967672557528897141063187618337453388;
113
- uint256 constant IC22y = 2781037153273060303563709335004469748385856874214113367257213722048722844628;
114
-
115
- uint256 constant IC23x = 563165185017277156586914590989610211146612393394745209502606921694411856770;
116
- uint256 constant IC23y = 1867875812539555179907306772686570618330295637834892371784793120325713160308;
117
-
118
- uint256 constant IC24x = 2457096394813884379686442634915495944375990912063278685286306284881036618033;
119
- uint256 constant IC24y = 9163446075990301051551079616945375045779417347203761606827124976128976017243;
120
-
121
- uint256 constant IC25x = 1743053317079366204996691475159512425883170811470216460647956533442828289763;
122
- uint256 constant IC25y = 13254806637989102281499220587994341892561856643160499096505399992507218188460;
123
-
124
- uint256 constant IC26x = 16457212763218512312029045980523021761185322886557104838380955364015299672621;
125
- uint256 constant IC26y = 3832051276327423572157341674930404819154207918912893988830189275467754156986;
126
-
127
- uint256 constant IC27x = 7066732793908631280585447768356572301661729178014215382425422621835198374934;
128
- uint256 constant IC27y = 20218049939976959412181995154352699629848842510077825918186645655758322949799;
129
-
130
- uint256 constant IC28x = 4956541933446787921484019161677028281341025665070293104310847504459808951902;
131
- uint256 constant IC28y = 3816612363672807131901364108187968999531661471090783307990812661940962728793;
132
-
133
- uint256 constant IC29x = 12864855763711014018937686464445079603876150271834557785727424395080640977375;
134
- uint256 constant IC29y = 17104460204202358952944264943384418106769657136663495962076435904655878943387;
135
-
136
- uint256 constant IC30x = 10733803698951847038628465307457406214043524434609329980970498315685711899399;
137
- uint256 constant IC30y = 16519409387955418716360723471116718454664493931458001942270816646266520269796;
138
-
139
- uint256 constant IC31x = 12909939941499886901966667410136137868262843958894123925049005285184892169544;
140
- uint256 constant IC31y = 1657402006410764881494628061552028843566153692545264489012332399729234496519;
141
-
142
- uint256 constant IC32x = 8775036978498508283490314935930852866490644815685499362701526620312348354401;
143
- uint256 constant IC32y = 19174451949836506203826461224948126006167386246436763884712123287530052126146;
144
-
145
- uint256 constant IC33x = 8247659400198328520625339530571568202176233065620852483501423510365143209162;
146
- uint256 constant IC33y = 12647517307362942578728139692382728564506863665352890035710170306742329147081;
147
-
148
-
149
- // Memory data
150
- uint16 constant pVk = 0;
151
- uint16 constant pPairing = 128;
152
-
153
- uint16 constant pLastMem = 896;
154
-
155
- function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[33] calldata _pubSignals) public view returns (bool) {
156
- assembly {
157
- function checkField(v) {
158
- if iszero(lt(v, r)) {
159
- mstore(0, 0)
160
- return(0, 0x20)
161
- }
162
- }
163
-
164
- // G1 function to multiply a G1 value(x,y) to value in an address
165
- function g1_mulAccC(pR, x, y, s) {
166
- let success
167
- let mIn := mload(0x40)
168
- mstore(mIn, x)
169
- mstore(add(mIn, 32), y)
170
- mstore(add(mIn, 64), s)
171
-
172
- success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
173
-
174
- if iszero(success) {
175
- mstore(0, 0)
176
- return(0, 0x20)
177
- }
178
-
179
- mstore(add(mIn, 64), mload(pR))
180
- mstore(add(mIn, 96), mload(add(pR, 32)))
181
-
182
- success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
183
-
184
- if iszero(success) {
185
- mstore(0, 0)
186
- return(0, 0x20)
187
- }
188
- }
189
-
190
- function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk {
191
- let _pPairing := add(pMem, pPairing)
192
- let _pVk := add(pMem, pVk)
193
-
194
- mstore(_pVk, IC0x)
195
- mstore(add(_pVk, 32), IC0y)
196
-
197
- // Compute the linear combination vk_x
198
-
199
- g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0)))
200
-
201
- g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
202
-
203
- g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
204
-
205
- g1_mulAccC(_pVk, IC4x, IC4y, calldataload(add(pubSignals, 96)))
206
-
207
- g1_mulAccC(_pVk, IC5x, IC5y, calldataload(add(pubSignals, 128)))
208
-
209
- g1_mulAccC(_pVk, IC6x, IC6y, calldataload(add(pubSignals, 160)))
210
-
211
- g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192)))
212
-
213
- g1_mulAccC(_pVk, IC8x, IC8y, calldataload(add(pubSignals, 224)))
214
-
215
- g1_mulAccC(_pVk, IC9x, IC9y, calldataload(add(pubSignals, 256)))
216
-
217
- g1_mulAccC(_pVk, IC10x, IC10y, calldataload(add(pubSignals, 288)))
218
-
219
- g1_mulAccC(_pVk, IC11x, IC11y, calldataload(add(pubSignals, 320)))
220
-
221
- g1_mulAccC(_pVk, IC12x, IC12y, calldataload(add(pubSignals, 352)))
222
-
223
- g1_mulAccC(_pVk, IC13x, IC13y, calldataload(add(pubSignals, 384)))
224
-
225
- g1_mulAccC(_pVk, IC14x, IC14y, calldataload(add(pubSignals, 416)))
226
-
227
- g1_mulAccC(_pVk, IC15x, IC15y, calldataload(add(pubSignals, 448)))
228
-
229
- g1_mulAccC(_pVk, IC16x, IC16y, calldataload(add(pubSignals, 480)))
230
-
231
- g1_mulAccC(_pVk, IC17x, IC17y, calldataload(add(pubSignals, 512)))
232
-
233
- g1_mulAccC(_pVk, IC18x, IC18y, calldataload(add(pubSignals, 544)))
234
-
235
- g1_mulAccC(_pVk, IC19x, IC19y, calldataload(add(pubSignals, 576)))
236
-
237
- g1_mulAccC(_pVk, IC20x, IC20y, calldataload(add(pubSignals, 608)))
238
-
239
- g1_mulAccC(_pVk, IC21x, IC21y, calldataload(add(pubSignals, 640)))
240
-
241
- g1_mulAccC(_pVk, IC22x, IC22y, calldataload(add(pubSignals, 672)))
242
-
243
- g1_mulAccC(_pVk, IC23x, IC23y, calldataload(add(pubSignals, 704)))
244
-
245
- g1_mulAccC(_pVk, IC24x, IC24y, calldataload(add(pubSignals, 736)))
246
-
247
- g1_mulAccC(_pVk, IC25x, IC25y, calldataload(add(pubSignals, 768)))
248
-
249
- g1_mulAccC(_pVk, IC26x, IC26y, calldataload(add(pubSignals, 800)))
250
-
251
- g1_mulAccC(_pVk, IC27x, IC27y, calldataload(add(pubSignals, 832)))
252
-
253
- g1_mulAccC(_pVk, IC28x, IC28y, calldataload(add(pubSignals, 864)))
254
-
255
- g1_mulAccC(_pVk, IC29x, IC29y, calldataload(add(pubSignals, 896)))
256
-
257
- g1_mulAccC(_pVk, IC30x, IC30y, calldataload(add(pubSignals, 928)))
258
-
259
- g1_mulAccC(_pVk, IC31x, IC31y, calldataload(add(pubSignals, 960)))
260
-
261
- g1_mulAccC(_pVk, IC32x, IC32y, calldataload(add(pubSignals, 992)))
262
-
263
- g1_mulAccC(_pVk, IC33x, IC33y, calldataload(add(pubSignals, 1024)))
264
-
265
-
266
- // -A
267
- mstore(_pPairing, calldataload(pA))
268
- mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
269
-
270
- // B
271
- mstore(add(_pPairing, 64), calldataload(pB))
272
- mstore(add(_pPairing, 96), calldataload(add(pB, 32)))
273
- mstore(add(_pPairing, 128), calldataload(add(pB, 64)))
274
- mstore(add(_pPairing, 160), calldataload(add(pB, 96)))
275
-
276
- // alpha1
277
- mstore(add(_pPairing, 192), alphax)
278
- mstore(add(_pPairing, 224), alphay)
279
-
280
- // beta2
281
- mstore(add(_pPairing, 256), betax1)
282
- mstore(add(_pPairing, 288), betax2)
283
- mstore(add(_pPairing, 320), betay1)
284
- mstore(add(_pPairing, 352), betay2)
285
-
286
- // vk_x
287
- mstore(add(_pPairing, 384), mload(add(pMem, pVk)))
288
- mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32))))
289
-
290
-
291
- // gamma2
292
- mstore(add(_pPairing, 448), gammax1)
293
- mstore(add(_pPairing, 480), gammax2)
294
- mstore(add(_pPairing, 512), gammay1)
295
- mstore(add(_pPairing, 544), gammay2)
296
-
297
- // C
298
- mstore(add(_pPairing, 576), calldataload(pC))
299
- mstore(add(_pPairing, 608), calldataload(add(pC, 32)))
300
-
301
- // delta2
302
- mstore(add(_pPairing, 640), deltax1)
303
- mstore(add(_pPairing, 672), deltax2)
304
- mstore(add(_pPairing, 704), deltay1)
305
- mstore(add(_pPairing, 736), deltay2)
306
-
307
-
308
- let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
309
-
310
- isOk := and(success, mload(_pPairing))
311
- }
312
-
313
- let pMem := mload(0x40)
314
- mstore(0x40, add(pMem, pLastMem))
315
-
316
- // Validate that all evaluations ∈ F
317
-
318
- checkField(calldataload(add(_pubSignals, 0)))
319
-
320
- checkField(calldataload(add(_pubSignals, 32)))
321
-
322
- checkField(calldataload(add(_pubSignals, 64)))
323
-
324
- checkField(calldataload(add(_pubSignals, 96)))
325
-
326
- checkField(calldataload(add(_pubSignals, 128)))
327
-
328
- checkField(calldataload(add(_pubSignals, 160)))
329
-
330
- checkField(calldataload(add(_pubSignals, 192)))
331
-
332
- checkField(calldataload(add(_pubSignals, 224)))
333
-
334
- checkField(calldataload(add(_pubSignals, 256)))
335
-
336
- checkField(calldataload(add(_pubSignals, 288)))
337
-
338
- checkField(calldataload(add(_pubSignals, 320)))
339
-
340
- checkField(calldataload(add(_pubSignals, 352)))
341
-
342
- checkField(calldataload(add(_pubSignals, 384)))
343
-
344
- checkField(calldataload(add(_pubSignals, 416)))
345
-
346
- checkField(calldataload(add(_pubSignals, 448)))
347
-
348
- checkField(calldataload(add(_pubSignals, 480)))
349
-
350
- checkField(calldataload(add(_pubSignals, 512)))
351
-
352
- checkField(calldataload(add(_pubSignals, 544)))
353
-
354
- checkField(calldataload(add(_pubSignals, 576)))
355
-
356
- checkField(calldataload(add(_pubSignals, 608)))
357
-
358
- checkField(calldataload(add(_pubSignals, 640)))
359
-
360
- checkField(calldataload(add(_pubSignals, 672)))
361
-
362
- checkField(calldataload(add(_pubSignals, 704)))
363
-
364
- checkField(calldataload(add(_pubSignals, 736)))
365
-
366
- checkField(calldataload(add(_pubSignals, 768)))
367
-
368
- checkField(calldataload(add(_pubSignals, 800)))
369
-
370
- checkField(calldataload(add(_pubSignals, 832)))
371
-
372
- checkField(calldataload(add(_pubSignals, 864)))
373
-
374
- checkField(calldataload(add(_pubSignals, 896)))
375
-
376
- checkField(calldataload(add(_pubSignals, 928)))
377
-
378
- checkField(calldataload(add(_pubSignals, 960)))
379
-
380
- checkField(calldataload(add(_pubSignals, 992)))
381
-
382
- checkField(calldataload(add(_pubSignals, 1024)))
383
-
384
-
385
- // Validate all evaluations
386
- let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
387
-
388
- mstore(0, isValid)
389
- return(0, 0x20)
390
- }
391
- }
392
- }
19
+ import {Verifier_AnonNullifierQurrencyTransferBatch} from "./impl/anon_nullifier_qurrency_transfer_batch.sol";
20
+
21
+ contract Groth16Verifier_AnonNullifierQurrencyTransferBatch is
22
+ Verifier_AnonNullifierQurrencyTransferBatch
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[120] 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,210 +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_AnonNullifierTransfer {
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 = 12965336239355451065377728838263564336455832852756106285329915889367179910844;
47
- uint256 constant IC0y = 21266717082765079145279107240791882967271935211887697534282840438802556611138;
48
-
49
- uint256 constant IC1x = 20415096428409244779003058634997676197645321938716463349566012895685648563129;
50
- uint256 constant IC1y = 2504850739252174842588245578954831308407351753661546676448248125715996228551;
51
-
52
- uint256 constant IC2x = 11538009073536561162431603046042378506434129710246113579796569619470355977356;
53
- uint256 constant IC2y = 18200656560016022729405688044864673805927167342575989505621039477255562885095;
54
-
55
- uint256 constant IC3x = 16060424900281789113856869053727496302295520075201955371229184101176742019112;
56
- uint256 constant IC3y = 7833246346420318094523191406657909832948492362877179000610063345430143769697;
57
-
58
- uint256 constant IC4x = 1167903139320461673730146790352309165100002152797819099757601178981873676571;
59
- uint256 constant IC4y = 12981611873802789105958141408359145370994325864169284450155625189242411024122;
60
-
61
- uint256 constant IC5x = 20773020415848698598468478160768655922713869022241397741152588611764469765759;
62
- uint256 constant IC5y = 3428403864418547287693751509569561378183428598972823612146679585580293690972;
63
-
64
- uint256 constant IC6x = 15674579346918082060062949471055203685989363986238424085033128428743473529013;
65
- uint256 constant IC6y = 9126381316540146842373796334750733369806543224338767018342599704279030186328;
66
-
67
- uint256 constant IC7x = 17375655877097475551894724405341759891777951116707914297938348038970054234761;
68
- uint256 constant IC7y = 17844212665933336469595879705672773898766845640145736759052525282105784315179;
69
-
70
-
71
- // Memory data
72
- uint16 constant pVk = 0;
73
- uint16 constant pPairing = 128;
74
-
75
- uint16 constant pLastMem = 896;
76
-
77
- function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[7] calldata _pubSignals) public view returns (bool) {
78
- assembly {
79
- function checkField(v) {
80
- if iszero(lt(v, r)) {
81
- mstore(0, 0)
82
- return(0, 0x20)
83
- }
84
- }
85
-
86
- // G1 function to multiply a G1 value(x,y) to value in an address
87
- function g1_mulAccC(pR, x, y, s) {
88
- let success
89
- let mIn := mload(0x40)
90
- mstore(mIn, x)
91
- mstore(add(mIn, 32), y)
92
- mstore(add(mIn, 64), s)
93
-
94
- success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
95
-
96
- if iszero(success) {
97
- mstore(0, 0)
98
- return(0, 0x20)
99
- }
100
-
101
- mstore(add(mIn, 64), mload(pR))
102
- mstore(add(mIn, 96), mload(add(pR, 32)))
103
-
104
- success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
105
-
106
- if iszero(success) {
107
- mstore(0, 0)
108
- return(0, 0x20)
109
- }
110
- }
111
-
112
- function checkPairing(pA, pB, pC, pubSignals, pMem) -> isOk {
113
- let _pPairing := add(pMem, pPairing)
114
- let _pVk := add(pMem, pVk)
115
-
116
- mstore(_pVk, IC0x)
117
- mstore(add(_pVk, 32), IC0y)
118
-
119
- // Compute the linear combination vk_x
120
-
121
- g1_mulAccC(_pVk, IC1x, IC1y, calldataload(add(pubSignals, 0)))
122
-
123
- g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
124
-
125
- g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
126
-
127
- g1_mulAccC(_pVk, IC4x, IC4y, calldataload(add(pubSignals, 96)))
128
-
129
- g1_mulAccC(_pVk, IC5x, IC5y, calldataload(add(pubSignals, 128)))
130
-
131
- g1_mulAccC(_pVk, IC6x, IC6y, calldataload(add(pubSignals, 160)))
132
-
133
- g1_mulAccC(_pVk, IC7x, IC7y, calldataload(add(pubSignals, 192)))
134
-
135
-
136
- // -A
137
- mstore(_pPairing, calldataload(pA))
138
- mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
139
-
140
- // B
141
- mstore(add(_pPairing, 64), calldataload(pB))
142
- mstore(add(_pPairing, 96), calldataload(add(pB, 32)))
143
- mstore(add(_pPairing, 128), calldataload(add(pB, 64)))
144
- mstore(add(_pPairing, 160), calldataload(add(pB, 96)))
145
-
146
- // alpha1
147
- mstore(add(_pPairing, 192), alphax)
148
- mstore(add(_pPairing, 224), alphay)
149
-
150
- // beta2
151
- mstore(add(_pPairing, 256), betax1)
152
- mstore(add(_pPairing, 288), betax2)
153
- mstore(add(_pPairing, 320), betay1)
154
- mstore(add(_pPairing, 352), betay2)
155
-
156
- // vk_x
157
- mstore(add(_pPairing, 384), mload(add(pMem, pVk)))
158
- mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32))))
159
-
160
-
161
- // gamma2
162
- mstore(add(_pPairing, 448), gammax1)
163
- mstore(add(_pPairing, 480), gammax2)
164
- mstore(add(_pPairing, 512), gammay1)
165
- mstore(add(_pPairing, 544), gammay2)
166
-
167
- // C
168
- mstore(add(_pPairing, 576), calldataload(pC))
169
- mstore(add(_pPairing, 608), calldataload(add(pC, 32)))
170
-
171
- // delta2
172
- mstore(add(_pPairing, 640), deltax1)
173
- mstore(add(_pPairing, 672), deltax2)
174
- mstore(add(_pPairing, 704), deltay1)
175
- mstore(add(_pPairing, 736), deltay2)
176
-
177
-
178
- let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
179
-
180
- isOk := and(success, mload(_pPairing))
181
- }
182
-
183
- let pMem := mload(0x40)
184
- mstore(0x40, add(pMem, pLastMem))
185
-
186
- // Validate that all evaluations ∈ F
187
-
188
- checkField(calldataload(add(_pubSignals, 0)))
189
-
190
- checkField(calldataload(add(_pubSignals, 32)))
191
-
192
- checkField(calldataload(add(_pubSignals, 64)))
193
-
194
- checkField(calldataload(add(_pubSignals, 96)))
195
-
196
- checkField(calldataload(add(_pubSignals, 128)))
197
-
198
- checkField(calldataload(add(_pubSignals, 160)))
199
-
200
- checkField(calldataload(add(_pubSignals, 192)))
201
-
202
-
203
- // Validate all evaluations
204
- let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
205
-
206
- mstore(0, isValid)
207
- return(0, 0x20)
208
- }
209
- }
210
- }
19
+ import {Verifier_AnonNullifierTransfer} from "./impl/anon_nullifier_transfer.sol";
20
+
21
+ contract Groth16Verifier_AnonNullifierTransfer is
22
+ Verifier_AnonNullifierTransfer
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[7] 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
+ }