@lfdecentralizedtrust/zeto-contracts 0.2.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -162
- package/contracts/factory.sol +30 -34
- package/contracts/factory_upgradeable.sol +11 -7
- package/contracts/lib/common/util.sol +40 -0
- package/contracts/lib/interfaces/ILockableCapability.sol +318 -0
- package/contracts/lib/interfaces/{izeto.sol → IZeto.sol} +13 -1
- package/contracts/lib/interfaces/{izeto_initializable.sol → IZetoInitializable.sol} +14 -12
- package/contracts/lib/interfaces/{izeto_kyc.sol → IZetoKyc.sol} +3 -3
- package/contracts/lib/interfaces/IZetoLockableCapability.sol +237 -0
- package/contracts/lib/interfaces/IZetoStorage.sol +106 -0
- package/contracts/lib/interfaces/{izeto_lockable.sol → IZetoVerifier.sol} +8 -21
- package/contracts/lib/registry.sol +74 -26
- package/contracts/lib/storage/base.sol +210 -0
- package/contracts/lib/storage/nullifier.sol +166 -0
- package/contracts/lib/zeto_common.sol +277 -28
- package/contracts/lib/zeto_fungible.sol +451 -33
- package/contracts/lib/zeto_fungible_base.sol +69 -0
- package/contracts/lib/zeto_fungible_burn.sol +83 -53
- package/contracts/lib/zeto_fungible_burn_nullifier.sol +115 -72
- package/contracts/lib/zeto_fungible_nullifier.sol +167 -0
- package/contracts/lib/zeto_lockable.sol +613 -0
- package/contracts/lib/zeto_non_fungible.sol +236 -0
- package/contracts/lib/zeto_non_fungible_base.sol +61 -0
- package/contracts/lib/zeto_non_fungible_nullifier.sol +61 -0
- package/contracts/test/escrow1.sol +90 -34
- package/contracts/test/escrow2.sol +64 -29
- package/contracts/test/qurrency.sol +10 -2
- package/contracts/test/smt.sol +6 -1
- package/contracts/test/tendecimals.sol +14 -12
- package/contracts/verifiers/impl/anon.sol +189 -0
- package/contracts/verifiers/impl/anon_batch.sol +301 -0
- package/contracts/verifiers/impl/anon_enc.sol +266 -0
- package/contracts/verifiers/impl/anon_enc_batch.sol +602 -0
- package/contracts/verifiers/impl/anon_enc_nullifier.sol +287 -0
- package/contracts/verifiers/impl/anon_enc_nullifier_batch.sol +679 -0
- package/contracts/verifiers/impl/anon_enc_nullifier_kyc.sol +294 -0
- package/contracts/verifiers/impl/anon_enc_nullifier_kyc_batch.sol +686 -0
- package/contracts/verifiers/impl/anon_enc_nullifier_non_repudiation.sol +413 -0
- package/contracts/verifiers/impl/anon_enc_nullifier_non_repudiation_batch.sol +1141 -0
- package/contracts/verifiers/impl/anon_nullifier_kyc_transfer.sol +217 -0
- package/contracts/verifiers/impl/anon_nullifier_kyc_transferLocked.sol +196 -0
- package/contracts/verifiers/impl/anon_nullifier_kyc_transferLocked_batch.sol +308 -0
- package/contracts/verifiers/impl/anon_nullifier_kyc_transfer_batch.sol +385 -0
- package/contracts/verifiers/impl/anon_nullifier_qurrency_transfer.sol +497 -0
- package/contracts/verifiers/impl/anon_nullifier_qurrency_transfer_batch.sol +1001 -0
- package/contracts/verifiers/{verifier_anon_nullifier_transferLocked.sol → impl/anon_nullifier_transfer.sol} +12 -19
- package/contracts/verifiers/{verifier_anon_nullifier_transferLocked_batch.sol → impl/anon_nullifier_transfer_batch.sol} +44 -51
- package/contracts/verifiers/impl/burn.sol +182 -0
- package/contracts/verifiers/impl/burn_batch.sol +238 -0
- package/contracts/verifiers/impl/burn_nullifier.sol +203 -0
- package/contracts/verifiers/impl/burn_nullifier_batch.sol +315 -0
- package/contracts/verifiers/impl/deposit.sol +182 -0
- package/contracts/verifiers/impl/deposit_kyc.sol +189 -0
- package/contracts/verifiers/impl/nf_anon.sol +175 -0
- package/contracts/verifiers/{verifier_nf_anon_nullifier_transferLocked.sol → impl/nf_anon_nullifier_transfer.sol} +6 -13
- package/contracts/verifiers/impl/withdraw.sol +189 -0
- package/contracts/verifiers/impl/withdraw_batch.sol +245 -0
- package/contracts/verifiers/impl/withdraw_nullifier.sol +210 -0
- package/contracts/verifiers/impl/withdraw_nullifier_batch.sol +322 -0
- package/contracts/verifiers/verifier_anon.sol +31 -186
- package/contracts/verifiers/verifier_anon_batch.sol +31 -298
- package/contracts/verifiers/verifier_anon_enc.sol +31 -263
- package/contracts/verifiers/verifier_anon_enc_batch.sol +31 -599
- package/contracts/verifiers/verifier_anon_enc_nullifier.sol +31 -284
- package/contracts/verifiers/verifier_anon_enc_nullifier_batch.sol +33 -676
- package/contracts/verifiers/verifier_anon_enc_nullifier_kyc.sol +31 -291
- package/contracts/verifiers/verifier_anon_enc_nullifier_kyc_batch.sol +33 -683
- package/contracts/verifiers/verifier_anon_enc_nullifier_non_repudiation.sol +33 -410
- package/contracts/verifiers/verifier_anon_enc_nullifier_non_repudiation_batch.sol +33 -1138
- package/contracts/verifiers/verifier_anon_nullifier_kyc_transfer.sol +33 -214
- package/contracts/verifiers/verifier_anon_nullifier_kyc_transferLocked.sol +33 -221
- package/contracts/verifiers/verifier_anon_nullifier_kyc_transferLocked_batch.sol +33 -389
- package/contracts/verifiers/verifier_anon_nullifier_kyc_transfer_batch.sol +33 -382
- package/contracts/verifiers/verifier_anon_nullifier_qurrency_transfer.sol +33 -221
- package/contracts/verifiers/verifier_anon_nullifier_qurrency_transfer_batch.sol +33 -389
- package/contracts/verifiers/verifier_anon_nullifier_transfer.sol +33 -207
- package/contracts/verifiers/verifier_anon_nullifier_transfer_batch.sol +33 -375
- package/contracts/verifiers/verifier_burn.sol +31 -179
- package/contracts/verifiers/verifier_burn_batch.sol +31 -235
- package/contracts/verifiers/verifier_burn_nullifier.sol +31 -200
- package/contracts/verifiers/verifier_burn_nullifier_batch.sol +31 -312
- package/contracts/verifiers/verifier_deposit.sol +31 -179
- package/contracts/verifiers/verifier_deposit_kyc.sol +34 -0
- package/contracts/verifiers/verifier_nf_anon.sol +31 -172
- package/contracts/verifiers/verifier_nf_anon_nullifier_transfer.sol +33 -179
- package/contracts/verifiers/verifier_withdraw.sol +31 -186
- package/contracts/verifiers/verifier_withdraw_batch.sol +31 -242
- package/contracts/verifiers/verifier_withdraw_nullifier.sol +31 -207
- package/contracts/verifiers/verifier_withdraw_nullifier_batch.sol +33 -319
- package/contracts/zeto_anon.sol +77 -231
- package/contracts/zeto_anon_burnable.sol +56 -12
- package/contracts/zeto_anon_enc.sol +93 -190
- package/contracts/zeto_anon_enc_nullifier.sol +249 -195
- package/contracts/zeto_anon_enc_nullifier_kyc.sol +51 -232
- package/contracts/zeto_anon_enc_nullifier_non_repudiation.sol +231 -238
- package/contracts/zeto_anon_nullifier.sol +164 -298
- package/contracts/zeto_anon_nullifier_burnable.sol +68 -18
- package/contracts/zeto_anon_nullifier_kyc.sol +40 -345
- package/contracts/zeto_anon_nullifier_qurrency.sol +217 -361
- package/contracts/zeto_nf_anon.sol +55 -130
- package/contracts/zeto_nf_anon_nullifier.sol +90 -152
- package/hardhat.config.ts +9 -3
- package/ignition/modules/lib/deps.ts +8 -0
- package/ignition/modules/zeto_anon_burnable.ts +8 -7
- package/ignition/modules/zeto_anon_enc_nullifier.ts +31 -0
- package/ignition/modules/zeto_anon_enc_nullifier_kyc.ts +2 -2
- package/ignition/modules/zeto_anon_nullifier.ts +28 -4
- package/ignition/modules/zeto_anon_nullifier_burnable.ts +50 -16
- package/ignition/modules/zeto_anon_nullifier_kyc.ts +27 -12
- package/ignition/modules/zeto_nf_anon_nullifier.ts +14 -10
- package/package.json +4 -2
- package/scripts/deploy_cloneable.ts +19 -10
- package/scripts/deploy_upgradeable.ts +9 -5
- package/scripts/tokens/Zeto_Anon.ts +3 -3
- package/scripts/tokens/Zeto_AnonBurnable.ts +1 -1
- package/scripts/tokens/Zeto_AnonEnc.ts +12 -3
- package/scripts/tokens/Zeto_AnonEncNullifier.ts +5 -3
- package/scripts/tokens/Zeto_AnonEncNullifierKyc.ts +1 -1
- package/scripts/tokens/Zeto_AnonEncNullifierNonRepudiation.ts +1 -1
- package/scripts/tokens/Zeto_AnonNullifier.ts +1 -1
- package/scripts/tokens/Zeto_AnonNullifierBurnable.ts +1 -1
- package/scripts/tokens/Zeto_AnonNullifierKyc.ts +1 -1
- package/scripts/tokens/Zeto_AnonNullifierQurrency.ts +1 -1
- package/scripts/tokens/Zeto_NfAnon.ts +2 -2
- package/scripts/tokens/Zeto_NfAnonNullifier.ts +1 -1
- package/test/factory.ts +46 -73
- package/test/lib/anon_nullifier_helpers.ts +89 -0
- package/test/lib/anon_zeto_helpers.ts +76 -0
- package/test/lib/deploy.ts +3 -2
- package/test/lib/utils.ts +74 -35
- package/test/test/escrow1.ts +185 -58
- package/test/test/escrow2.ts +200 -107
- package/test/test/qurrency.ts +13 -33
- package/test/usdc-shielding.ts +39 -26
- package/test/utils.ts +144 -21
- package/test/zeto_anon.ts +956 -465
- package/test/zeto_anon_enc.ts +881 -142
- package/test/zeto_anon_enc_nullifier.ts +847 -38
- package/test/zeto_anon_enc_nullifier_kyc.ts +120 -181
- package/test/zeto_anon_enc_nullifier_non_repudiation.ts +77 -46
- package/test/zeto_anon_nullifier.ts +1212 -953
- package/test/zeto_anon_nullifier_kyc.ts +674 -655
- package/test/zeto_anon_nullifier_qurrency.ts +452 -306
- package/test/zeto_nf_anon.ts +737 -137
- package/test/zeto_nf_anon_nullifier.ts +876 -246
- package/contracts/lib/zeto_base.sol +0 -293
- package/contracts/lib/zeto_fungible_withdraw.sol +0 -132
- package/contracts/lib/zeto_fungible_withdraw_nullifier.sol +0 -144
- package/contracts/lib/zeto_nullifier.sol +0 -340
- package/contracts/zkDvP.sol_ +0 -273
- package/test/zkDvP.ts_ +0 -455
- /package/contracts/lib/{common.sol → common/common.sol} +0 -0
|
@@ -15,256 +15,75 @@
|
|
|
15
15
|
// limitations under the License.
|
|
16
16
|
pragma solidity ^0.8.27;
|
|
17
17
|
|
|
18
|
-
import {
|
|
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 {
|
|
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
|
-
|
|
32
|
-
|
|
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
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
|
56
|
-
string
|
|
48
|
+
string calldata name,
|
|
49
|
+
string calldata symbol,
|
|
57
50
|
address initialOwner,
|
|
58
51
|
IZetoInitializable.VerifiersInfo calldata verifiers
|
|
59
|
-
) public initializer {
|
|
60
|
-
|
|
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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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
|
}
|