@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
@@ -15,256 +15,75 @@
15
15
  // limitations under the License.
16
16
  pragma solidity ^0.8.27;
17
17
 
18
- import {IZeto} from "./lib/interfaces/izeto.sol";
19
- import {Groth16Verifier_Deposit} from "./verifiers/verifier_deposit.sol";
20
- import {Groth16Verifier_WithdrawNullifier} from "./verifiers/verifier_withdraw_nullifier.sol";
21
- import {Groth16Verifier_WithdrawNullifierBatch} from "./verifiers/verifier_withdraw_nullifier_batch.sol";
22
- import {Groth16Verifier_AnonEncNullifierKyc} from "./verifiers/verifier_anon_enc_nullifier_kyc.sol";
23
- import {Groth16Verifier_AnonEncNullifierKycBatch} from "./verifiers/verifier_anon_enc_nullifier_kyc_batch.sol";
24
- import {ZetoNullifier} from "./lib/zeto_nullifier.sol";
25
- import {ZetoFungibleWithdrawWithNullifiers} from "./lib/zeto_fungible_withdraw_nullifier.sol";
18
+ import {Zeto_AnonEncNullifier} from "./zeto_anon_enc_nullifier.sol";
26
19
  import {Registry} from "./lib/registry.sol";
27
- import {Commonlib} from "./lib/common.sol";
28
- import {IZetoInitializable} from "./lib/interfaces/izeto_initializable.sol";
29
- import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
20
+ import {IZetoInitializable} from "./lib/interfaces/IZetoInitializable.sol";
30
21
 
31
- uint256 constant INPUT_SIZE = 19;
32
- uint256 constant BATCH_INPUT_SIZE = 75;
33
-
34
- /// @title A sample implementation of a Zeto based fungible token with anonymity, encryption and history masking
22
+ /// @title A sample implementation of a Zeto based fungible token with
23
+ /// anonymity, encryption, history masking via nullifiers, and KYC.
35
24
  /// @author Kaleido, Inc.
25
+ /// @notice Decimals: this token uses **4** decimals, inherited from
26
+ /// {ZetoCommon.decimals}. Indexers and UIs reading this contract
27
+ /// directly should treat balances accordingly.
36
28
  /// @dev The proof has the following statements:
37
29
  /// - each value in the output commitments must be a positive number in the range 0 ~ (2\*\*40 - 1)
38
30
  /// - the sum of the nullified values match the sum of output values
39
31
  /// - the hashes in the input and output match the hash(value, salt, owner public key) formula
40
32
  /// - the sender possesses the private BabyJubjub key, whose public key is part of the pre-image of the input commitment hashes, which match the corresponding nullifiers
41
- /// - the encrypted value in the input is derived from the receiver's UTXO value and encrypted with a shared secret using the ECDH protocol between the sender and receiver (this guarantees data availability for the receiver)
33
+ /// - the encrypted value in the output is derived from the receiver's UTXO value and encrypted with a shared secret using the ECDH protocol between the sender and receiver
42
34
  /// - the nullifiers represent input commitments that are included in a Sparse Merkle Tree represented by the root hash
43
- contract Zeto_AnonEncNullifierKyc is
44
- IZeto,
45
- IZetoInitializable,
46
- ZetoNullifier,
47
- ZetoFungibleWithdrawWithNullifiers,
48
- Registry,
49
- UUPSUpgradeable
50
- {
51
- Groth16Verifier_AnonEncNullifierKyc internal _verifier;
52
- Groth16Verifier_AnonEncNullifierKycBatch internal _batchVerifier;
35
+ /// - the input/output owners are members of the {Registry}'s identities tree
36
+ contract Zeto_AnonEncNullifierKyc is Zeto_AnonEncNullifier, Registry {
37
+ /// @dev Lock the implementation contract on construction. The parent
38
+ /// {Zeto_AnonEncNullifier} already does this via its own
39
+ /// constructor (which Solidity invokes as part of every leaf's
40
+ /// deployment), but we restate it here so the H-2 protection
41
+ /// survives any future refactor that changes the inheritance graph.
42
+ /// @custom:oz-upgrades-unsafe-allow constructor
43
+ constructor() {
44
+ _disableInitializers();
45
+ }
53
46
 
54
47
  function initialize(
55
- string memory name,
56
- string memory symbol,
48
+ string calldata name,
49
+ string calldata symbol,
57
50
  address initialOwner,
58
51
  IZetoInitializable.VerifiersInfo calldata verifiers
59
- ) public initializer {
60
- __Registry_init();
61
- __ZetoNullifier_init(name, symbol, initialOwner);
62
- __ZetoFungibleWithdrawWithNullifiers_init(
63
- (Groth16Verifier_Deposit)(verifiers.depositVerifier),
64
- (Groth16Verifier_WithdrawNullifier)(verifiers.withdrawVerifier),
65
- (Groth16Verifier_WithdrawNullifierBatch)(
66
- verifiers.batchWithdrawVerifier
67
- )
68
- );
69
- _verifier = (Groth16Verifier_AnonEncNullifierKyc)(verifiers.verifier);
70
- _batchVerifier = (Groth16Verifier_AnonEncNullifierKycBatch)(
71
- verifiers.batchVerifier
72
- );
73
- }
74
-
75
- function _authorizeUpgrade(address) internal override onlyOwner {}
76
-
77
- function constructPublicInputs(
78
- uint256[] memory nullifiers,
79
- uint256[] memory outputs,
80
- uint256 root,
81
- uint256 encryptionNonce,
82
- uint256[2] memory ecdhPublicKey,
83
- uint256[] memory encryptedValues,
84
- uint256 size
85
- ) internal view returns (uint256[] memory publicInputs) {
86
- publicInputs = new uint256[](size);
87
- uint256 piIndex = 0;
88
- // copy the ecdh public key
89
- for (uint256 i = 0; i < ecdhPublicKey.length; ++i) {
90
- publicInputs[piIndex++] = ecdhPublicKey[i];
91
- }
92
- // copy the encrypted value, salt and parity bit
93
- for (uint256 i = 0; i < encryptedValues.length; ++i) {
94
- publicInputs[piIndex++] = encryptedValues[i];
95
- }
96
- // copy input commitments
97
- for (uint256 i = 0; i < nullifiers.length; i++) {
98
- publicInputs[piIndex++] = nullifiers[i];
99
- }
100
-
101
- // copy root
102
- publicInputs[piIndex++] = root;
103
-
104
- // populate enables
105
- for (uint256 i = 0; i < nullifiers.length; i++) {
106
- publicInputs[piIndex++] = (nullifiers[i] == 0) ? 0 : 1;
107
- }
108
-
109
- // copy identities root
110
- publicInputs[piIndex++] = getIdentitiesRoot();
111
- // copy output commitments
112
- for (uint256 i = 0; i < outputs.length; i++) {
113
- publicInputs[piIndex++] = outputs[i];
114
- }
115
-
116
- // copy encryption nonce
117
- publicInputs[piIndex++] = encryptionNonce;
118
-
119
- return publicInputs;
52
+ ) public override initializer {
53
+ __ZetoAnonEncNullifierKyc_init(name, symbol, initialOwner, verifiers);
120
54
  }
121
55
 
122
- /**
123
- * @dev the main function of the contract, which transfers values from one account (represented by Babyjubjub public keys)
124
- * to one or more receiver accounts (also represented by Babyjubjub public keys). One of the two nullifiers may be zero
125
- * if the transaction only needs one UTXO to be spent. Equally one of the two outputs may be zero if the transaction
126
- * only needs to create one new UTXO.
127
- *
128
- * @param nullifiers Array of nullifiers that are secretly bound to UTXOs to be spent by the transaction.
129
- * @param outputs Array of new UTXOs to generate, for future transactions to spend.
130
- * @param root The root hash of the Sparse Merkle Tree that contains the nullifiers.
131
- * @param proof A zero knowledge proof that the submitter is authorized to spend the inputs, and
132
- * that the outputs are valid in terms of obeying mass conservation rules.
133
- *
134
- * Emits a {UTXOTransferWithEncryptedValues} event.
135
- */
136
- function transfer(
137
- uint256[] memory nullifiers,
138
- uint256[] memory outputs,
139
- uint256 root,
140
- uint256 encryptionNonce,
141
- uint256[2] memory ecdhPublicKey,
142
- uint256[] memory encryptedValues,
143
- Commonlib.Proof calldata proof,
144
- bytes calldata data
145
- ) public returns (bool) {
146
- // Check and pad commitments
147
- nullifiers = checkAndPadCommitments(nullifiers);
148
- outputs = checkAndPadCommitments(outputs);
149
- validateTransactionProposal(nullifiers, outputs, root, false);
150
-
151
- // Check the proof
152
- if (nullifiers.length > 2 || outputs.length > 2) {
153
- uint256[] memory publicInputs = constructPublicInputs(
154
- nullifiers,
155
- outputs,
156
- root,
157
- encryptionNonce,
158
- ecdhPublicKey,
159
- encryptedValues,
160
- BATCH_INPUT_SIZE
161
- );
162
- // construct the public inputs for batchVerifier
163
- uint256[BATCH_INPUT_SIZE] memory fixedSizeInputs;
164
- for (uint256 i = 0; i < fixedSizeInputs.length; i++) {
165
- fixedSizeInputs[i] = publicInputs[i];
166
- }
167
-
168
- // Check the proof using batchVerifier
169
- require(
170
- _batchVerifier.verifyProof(
171
- proof.pA,
172
- proof.pB,
173
- proof.pC,
174
- fixedSizeInputs
175
- ),
176
- "Invalid proof (batch)"
177
- );
178
- } else {
179
- uint256[] memory publicInputs = constructPublicInputs(
180
- nullifiers,
181
- outputs,
182
- root,
183
- encryptionNonce,
184
- ecdhPublicKey,
185
- encryptedValues,
186
- INPUT_SIZE
187
- );
188
- // construct the public inputs for verifier
189
- uint256[INPUT_SIZE] memory fixedSizeInputs;
190
- for (uint256 i = 0; i < fixedSizeInputs.length; i++) {
191
- fixedSizeInputs[i] = publicInputs[i];
192
- }
193
- // Check the proof
194
- require(
195
- _verifier.verifyProof(
196
- proof.pA,
197
- proof.pB,
198
- proof.pC,
199
- fixedSizeInputs
200
- ),
201
- "Invalid proof"
202
- );
203
- }
204
-
205
- // accept the transaction to consume the input UTXOs and produce new UTXOs
206
- uint256[] memory empty;
207
- processInputsAndOutputs(nullifiers, outputs, empty, address(0));
208
-
209
- uint256[] memory encryptedValuesArray = new uint256[](
210
- encryptedValues.length
211
- );
212
- for (uint256 i = 0; i < encryptedValues.length; ++i) {
213
- encryptedValuesArray[i] = encryptedValues[i];
214
- }
215
-
216
- emit UTXOTransferWithEncryptedValues(
217
- nullifiers,
218
- outputs,
219
- encryptionNonce,
220
- ecdhPublicKey,
221
- encryptedValuesArray,
222
- msg.sender,
223
- data
224
- );
225
- return true;
226
- }
227
-
228
- // in the current design, no KYC check is performed for deposit & withdraw functions
229
- // this is to reduce gas fee for deposit and withdraw function
230
- // users that doesn't pass KYC check will not be able to participate in transfers
231
- // because the transfer circuit requires the input and output owners to be in the KYC list
232
- // Therefore, token circulation from & to parties that are not in the KYC list is prevented
233
- function deposit(
234
- uint256 amount,
235
- uint256[] memory outputs,
236
- Commonlib.Proof calldata proof,
237
- bytes calldata data
238
- ) public {
239
- _deposit(amount, outputs, proof);
240
- _mint(outputs, data);
56
+ function __ZetoAnonEncNullifierKyc_init(
57
+ string calldata name_,
58
+ string calldata symbol_,
59
+ address initialOwner,
60
+ IZetoInitializable.VerifiersInfo calldata verifiers
61
+ ) internal onlyInitializing {
62
+ __ZetoAnonEncNullifier_init(name_, symbol_, initialOwner, verifiers);
63
+ __Registry_init();
241
64
  }
242
65
 
243
- function withdraw(
244
- uint256 amount,
245
- uint256[] memory nullifiers,
246
- uint256 output,
247
- uint256 root,
248
- Commonlib.Proof calldata proof,
249
- bytes calldata data
250
- ) public {
251
- uint256[] memory outputs = new uint256[](nullifiers.length);
252
- outputs[0] = output;
253
- // Check and pad commitments
254
- nullifiers = checkAndPadCommitments(nullifiers);
255
- outputs = checkAndPadCommitments(outputs);
256
- validateTransactionProposal(nullifiers, outputs, root, false);
257
-
258
- _withdrawWithNullifiers(amount, nullifiers, output, root, proof);
259
- uint256[] memory empty;
260
- processInputsAndOutputs(nullifiers, outputs, empty, address(0));
261
- emit UTXOWithdraw(amount, nullifiers, output, msg.sender, data);
66
+ function extraInputs()
67
+ internal
68
+ view
69
+ virtual
70
+ override
71
+ returns (uint256[] memory)
72
+ {
73
+ uint256[] memory extras = new uint256[](1);
74
+ extras[0] = getIdentitiesRoot();
75
+ return extras;
262
76
  }
263
77
 
264
- function mint(
265
- uint256[] memory utxos,
266
- bytes calldata data
267
- ) public onlyOwner {
268
- _mint(utxos, data);
78
+ function extraInputsForDeposit()
79
+ internal
80
+ view
81
+ virtual
82
+ override
83
+ returns (uint256[] memory)
84
+ {
85
+ uint256[] memory extras = new uint256[](1);
86
+ extras[0] = getIdentitiesRoot();
87
+ return extras;
269
88
  }
270
89
  }