@lfdecentralizedtrust/zeto-contracts 0.5.0 → 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.
- package/README.md +6 -0
- package/config/eip170.ts +30 -0
- package/contracts/lib/interfaces/IZetoLockHooks.sol +42 -0
- package/contracts/lib/zeto_fungible.sol +9 -17
- package/contracts/lib/zeto_lockable.sol +85 -479
- package/contracts/lib/zeto_lockable_lib.sol +460 -0
- package/contracts/lib/zeto_lockable_storage.sol +43 -0
- package/contracts/lib/zeto_non_fungible.sol +8 -16
- package/hardhat.config.ts +11 -2
- package/ignition/modules/lib/deps.ts +5 -0
- package/ignition/modules/test/tendecimals.ts +7 -1
- package/ignition/modules/zeto_anon.ts +3 -0
- package/ignition/modules/zeto_anon_burnable.ts +3 -0
- package/ignition/modules/zeto_anon_enc.ts +3 -0
- package/ignition/modules/zeto_anon_enc_nullifier.ts +3 -0
- package/ignition/modules/zeto_anon_enc_nullifier_kyc.ts +3 -0
- package/ignition/modules/zeto_anon_enc_nullifier_non_repudiation.ts +3 -0
- package/ignition/modules/zeto_anon_nullifier.ts +3 -0
- package/ignition/modules/zeto_anon_nullifier_burnable.ts +3 -0
- package/ignition/modules/zeto_anon_nullifier_kyc.ts +3 -0
- package/ignition/modules/zeto_anon_nullifier_qurrency.ts +3 -0
- package/ignition/modules/zeto_nf_anon.ts +3 -1
- package/ignition/modules/zeto_nf_anon_nullifier.ts +3 -2
- package/package.json +4 -2
- package/scripts/lib/zeto_libraries.ts +47 -0
- package/scripts/tokens/Zeto_Anon.ts +3 -0
- package/scripts/tokens/Zeto_AnonBurnable.ts +3 -0
- package/scripts/tokens/Zeto_AnonEnc.ts +3 -0
- package/scripts/tokens/Zeto_AnonEncNullifier.ts +6 -5
- package/scripts/tokens/Zeto_AnonEncNullifierKyc.ts +6 -5
- package/scripts/tokens/Zeto_AnonEncNullifierNonRepudiation.ts +6 -5
- package/scripts/tokens/Zeto_AnonNullifier.ts +6 -5
- package/scripts/tokens/Zeto_AnonNullifierBurnable.ts +6 -5
- package/scripts/tokens/Zeto_AnonNullifierKyc.ts +6 -5
- package/scripts/tokens/Zeto_AnonNullifierQurrency.ts +6 -7
- package/scripts/tokens/Zeto_NfAnon.ts +3 -1
- package/scripts/tokens/Zeto_NfAnonNullifier.ts +6 -6
- package/test/factory.ts +10 -1
- package/test/lib/deploy.ts +2 -0
- package/test/lib/eip170.ts +23 -0
- package/test/usdc-shielding.ts +0 -1
- package/test/zeto_anon_enc.ts +0 -1
- package/test/zeto_anon_enc_nullifier.ts +3 -1
- package/test/zeto_anon_enc_nullifier_kyc.ts +3 -1
- package/test/zeto_anon_enc_nullifier_non_repudiation.ts +3 -1
- package/test/zeto_anon_nullifier.ts +0 -1
- package/test/zeto_anon_nullifier_kyc.ts +3 -1
- package/test/zeto_anon_nullifier_qurrency.ts +3 -1
- package/test/zeto_nf_anon.ts +0 -1
- package/test/zeto_nf_anon_nullifier.ts +0 -1
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
DepositVerifierModule,
|
|
21
21
|
WithdrawNullifierVerifierModule,
|
|
22
22
|
BatchWithdrawNullifierVerifierModule,
|
|
23
|
+
ZetoLockableLibModule,
|
|
23
24
|
} from "./lib/deps";
|
|
24
25
|
|
|
25
26
|
const VerifierModule = buildModule("Groth16Verifier_AnonEncNullifier", (m) => {
|
|
@@ -63,6 +64,7 @@ const BatchLockVerifierModule = buildModule(
|
|
|
63
64
|
);
|
|
64
65
|
|
|
65
66
|
export default buildModule("Zeto_AnonEncNullifier", (m) => {
|
|
67
|
+
const { zetoLockableLib } = m.useModule(ZetoLockableLibModule);
|
|
66
68
|
const { smtLib, poseidon2, poseidon3 } = m.useModule(SmtLibModule);
|
|
67
69
|
const { verifier } = m.useModule(VerifierModule);
|
|
68
70
|
const { verifier: lockVerifier } = m.useModule(LockVerifierModule);
|
|
@@ -87,5 +89,6 @@ export default buildModule("Zeto_AnonEncNullifier", (m) => {
|
|
|
87
89
|
smtLib,
|
|
88
90
|
poseidon2,
|
|
89
91
|
poseidon3,
|
|
92
|
+
zetoLockableLib,
|
|
90
93
|
};
|
|
91
94
|
});
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
DepositKycVerifierModule,
|
|
21
21
|
WithdrawNullifierVerifierModule,
|
|
22
22
|
BatchWithdrawNullifierVerifierModule,
|
|
23
|
+
ZetoLockableLibModule,
|
|
23
24
|
} from "./lib/deps";
|
|
24
25
|
|
|
25
26
|
const VerifierModule = buildModule(
|
|
@@ -39,6 +40,7 @@ const BatchVerifierModule = buildModule(
|
|
|
39
40
|
);
|
|
40
41
|
|
|
41
42
|
export default buildModule("Zeto_AnonEncNullifierKyc", (m) => {
|
|
43
|
+
const { zetoLockableLib } = m.useModule(ZetoLockableLibModule);
|
|
42
44
|
const { smtLib, poseidon2, poseidon3 } = m.useModule(SmtLibModule);
|
|
43
45
|
const { verifier } = m.useModule(VerifierModule);
|
|
44
46
|
const { verifier: batchVerifier } = m.useModule(BatchVerifierModule);
|
|
@@ -59,5 +61,6 @@ export default buildModule("Zeto_AnonEncNullifierKyc", (m) => {
|
|
|
59
61
|
smtLib,
|
|
60
62
|
poseidon2,
|
|
61
63
|
poseidon3,
|
|
64
|
+
zetoLockableLib,
|
|
62
65
|
};
|
|
63
66
|
});
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
DepositVerifierModule,
|
|
21
21
|
WithdrawNullifierVerifierModule,
|
|
22
22
|
BatchWithdrawNullifierVerifierModule,
|
|
23
|
+
ZetoLockableLibModule,
|
|
23
24
|
} from "./lib/deps";
|
|
24
25
|
|
|
25
26
|
const VerifierModule = buildModule(
|
|
@@ -45,6 +46,7 @@ const BatchVerifierModule = buildModule(
|
|
|
45
46
|
);
|
|
46
47
|
|
|
47
48
|
export default buildModule("Zeto_AnonEncNullifierNonRepudiation", (m) => {
|
|
49
|
+
const { zetoLockableLib } = m.useModule(ZetoLockableLibModule);
|
|
48
50
|
const { smtLib, poseidon2, poseidon3 } = m.useModule(SmtLibModule);
|
|
49
51
|
const { verifier } = m.useModule(VerifierModule);
|
|
50
52
|
const { verifier: batchVerifier } = m.useModule(BatchVerifierModule);
|
|
@@ -64,5 +66,6 @@ export default buildModule("Zeto_AnonEncNullifierNonRepudiation", (m) => {
|
|
|
64
66
|
smtLib,
|
|
65
67
|
poseidon2,
|
|
66
68
|
poseidon3,
|
|
69
|
+
zetoLockableLib,
|
|
67
70
|
};
|
|
68
71
|
});
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
DepositVerifierModule,
|
|
21
21
|
WithdrawNullifierVerifierModule,
|
|
22
22
|
BatchWithdrawNullifierVerifierModule,
|
|
23
|
+
ZetoLockableLibModule,
|
|
23
24
|
} from "./lib/deps";
|
|
24
25
|
|
|
25
26
|
const VerifierModule = buildModule(
|
|
@@ -88,6 +89,7 @@ const BatchLockVerifierModule = buildModule(
|
|
|
88
89
|
);
|
|
89
90
|
|
|
90
91
|
export default buildModule("Zeto_AnonNullifier", (m) => {
|
|
92
|
+
const { zetoLockableLib } = m.useModule(ZetoLockableLibModule);
|
|
91
93
|
const { smtLib, poseidon2, poseidon3 } = m.useModule(SmtLibModule);
|
|
92
94
|
const { verifier } = m.useModule(VerifierModule);
|
|
93
95
|
const { verifier: lockVerifier } = m.useModule(LockVerifierModule);
|
|
@@ -112,5 +114,6 @@ export default buildModule("Zeto_AnonNullifier", (m) => {
|
|
|
112
114
|
smtLib,
|
|
113
115
|
poseidon2,
|
|
114
116
|
poseidon3,
|
|
117
|
+
zetoLockableLib,
|
|
115
118
|
};
|
|
116
119
|
});
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
DepositVerifierModule,
|
|
21
21
|
WithdrawNullifierVerifierModule,
|
|
22
22
|
BatchWithdrawNullifierVerifierModule,
|
|
23
|
+
ZetoLockableLibModule,
|
|
23
24
|
} from "./lib/deps";
|
|
24
25
|
|
|
25
26
|
const VerifierModule = buildModule(
|
|
@@ -104,6 +105,7 @@ const BatchBurnNullifierVerifierModule = buildModule(
|
|
|
104
105
|
);
|
|
105
106
|
|
|
106
107
|
export default buildModule("Zeto_AnonNullifier", (m) => {
|
|
108
|
+
const { zetoLockableLib } = m.useModule(ZetoLockableLibModule);
|
|
107
109
|
const { smtLib, poseidon2, poseidon3 } = m.useModule(SmtLibModule);
|
|
108
110
|
const { verifier } = m.useModule(VerifierModule);
|
|
109
111
|
const { verifier: lockVerifier } = m.useModule(LockVerifierModule);
|
|
@@ -134,5 +136,6 @@ export default buildModule("Zeto_AnonNullifier", (m) => {
|
|
|
134
136
|
smtLib,
|
|
135
137
|
poseidon2,
|
|
136
138
|
poseidon3,
|
|
139
|
+
zetoLockableLib,
|
|
137
140
|
};
|
|
138
141
|
});
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
WithdrawNullifierVerifierModule,
|
|
21
21
|
BatchWithdrawNullifierVerifierModule,
|
|
22
22
|
DepositKycVerifierModule,
|
|
23
|
+
ZetoLockableLibModule,
|
|
23
24
|
} from "./lib/deps";
|
|
24
25
|
|
|
25
26
|
const VerifierModule = buildModule(
|
|
@@ -64,6 +65,7 @@ const BatchLockVerifierModule = buildModule(
|
|
|
64
65
|
);
|
|
65
66
|
|
|
66
67
|
export default buildModule("Zeto_AnonNullifierKyc", (m) => {
|
|
68
|
+
const { zetoLockableLib } = m.useModule(ZetoLockableLibModule);
|
|
67
69
|
const { smtLib, poseidon2, poseidon3 } = m.useModule(SmtLibModule);
|
|
68
70
|
const { verifier } = m.useModule(VerifierModule);
|
|
69
71
|
const { verifier: batchVerifier } = m.useModule(BatchVerifierModule);
|
|
@@ -88,5 +90,6 @@ export default buildModule("Zeto_AnonNullifierKyc", (m) => {
|
|
|
88
90
|
smtLib,
|
|
89
91
|
poseidon2,
|
|
90
92
|
poseidon3,
|
|
93
|
+
zetoLockableLib,
|
|
91
94
|
};
|
|
92
95
|
});
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
DepositVerifierModule,
|
|
21
21
|
WithdrawNullifierVerifierModule,
|
|
22
22
|
BatchWithdrawNullifierVerifierModule,
|
|
23
|
+
ZetoLockableLibModule,
|
|
23
24
|
} from "./lib/deps";
|
|
24
25
|
|
|
25
26
|
const VerifierModule = buildModule(
|
|
@@ -64,6 +65,7 @@ const BatchVerifierModule = buildModule(
|
|
|
64
65
|
// );
|
|
65
66
|
|
|
66
67
|
export default buildModule("Zeto_AnonNullifierQurrency", (m) => {
|
|
68
|
+
const { zetoLockableLib } = m.useModule(ZetoLockableLibModule);
|
|
67
69
|
const { smtLib, poseidon2, poseidon3, poseidon5, poseidon6 } = m.useModule(SmtLibModule);
|
|
68
70
|
const { verifier } = m.useModule(VerifierModule);
|
|
69
71
|
// const { verifier: lockVerifier } = m.useModule(LockVerifierModule);
|
|
@@ -90,5 +92,6 @@ export default buildModule("Zeto_AnonNullifierQurrency", (m) => {
|
|
|
90
92
|
poseidon3,
|
|
91
93
|
poseidon5,
|
|
92
94
|
poseidon6,
|
|
95
|
+
zetoLockableLib,
|
|
93
96
|
};
|
|
94
97
|
});
|
|
@@ -15,13 +15,15 @@
|
|
|
15
15
|
// limitations under the License.
|
|
16
16
|
|
|
17
17
|
import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";
|
|
18
|
+
import { ZetoLockableLibModule } from "./lib/deps";
|
|
18
19
|
const VerifierModule = buildModule("Groth16Verifier_NfAnon", (m) => {
|
|
19
20
|
const verifier = m.contract("Groth16Verifier_NfAnon", []);
|
|
20
21
|
return { verifier };
|
|
21
22
|
});
|
|
22
23
|
|
|
23
24
|
export default buildModule("Zeto_NfAnon", (m) => {
|
|
25
|
+
const { zetoLockableLib } = m.useModule(ZetoLockableLibModule);
|
|
24
26
|
const { verifier } = m.useModule(VerifierModule);
|
|
25
27
|
|
|
26
|
-
return { verifier };
|
|
28
|
+
return { verifier, zetoLockableLib };
|
|
27
29
|
});
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// limitations under the License.
|
|
16
16
|
|
|
17
17
|
import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";
|
|
18
|
-
import { SmtLibModule } from "./lib/deps";
|
|
18
|
+
import { SmtLibModule, ZetoLockableLibModule } from "./lib/deps";
|
|
19
19
|
|
|
20
20
|
const VerifierModule = buildModule(
|
|
21
21
|
"Groth16Verifier_NfAnonNullifierTransfer",
|
|
@@ -41,9 +41,10 @@ const LockVerifierModule = buildModule("Groth16Verifier_NfAnon", (m) => {
|
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
export default buildModule("Zeto_NfAnonNullifier", (m) => {
|
|
44
|
+
const { zetoLockableLib } = m.useModule(ZetoLockableLibModule);
|
|
44
45
|
const { smtLib, poseidon2, poseidon3 } = m.useModule(SmtLibModule);
|
|
45
46
|
const { verifier } = m.useModule(VerifierModule);
|
|
46
47
|
const { verifier: lockVerifier } = m.useModule(LockVerifierModule);
|
|
47
48
|
|
|
48
|
-
return { verifier, lockVerifier, smtLib, poseidon2, poseidon3 };
|
|
49
|
+
return { verifier, lockVerifier, smtLib, poseidon2, poseidon3, zetoLockableLib };
|
|
49
50
|
});
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lfdecentralizedtrust/zeto-contracts",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Zero knowledge proof based UTXO tokens toolkit for fungible or non-fungible assets",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prettier": "npx prettier contracts scripts ignition test --check",
|
|
8
8
|
"prettier:fix": "npm run prettier -- --write",
|
|
9
9
|
"pretest": "npm run prettier:fix",
|
|
10
|
-
"test": "npx hardhat test"
|
|
10
|
+
"test": "npx hardhat test",
|
|
11
|
+
"size": "npx hardhat size-contracts"
|
|
11
12
|
},
|
|
12
13
|
"keywords": [],
|
|
13
14
|
"repository": {
|
|
@@ -21,6 +22,7 @@
|
|
|
21
22
|
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.0",
|
|
22
23
|
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
|
|
23
24
|
"circomlibjs": "^0.1.7",
|
|
25
|
+
"hardhat-contract-sizer": "^2.10.1",
|
|
24
26
|
"maci-crypto": "1.1.1",
|
|
25
27
|
"mlkem": "^2.3.1",
|
|
26
28
|
"prettier": "^3.3.3",
|
|
@@ -0,0 +1,47 @@
|
|
|
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.
|
|
16
|
+
|
|
17
|
+
/** Hardhat library link map for Zeto token implementations. */
|
|
18
|
+
export function withZetoLockableLib(
|
|
19
|
+
zetoLockableLib: { target: string },
|
|
20
|
+
extra: Record<string, string> = {},
|
|
21
|
+
): Record<string, string> {
|
|
22
|
+
return {
|
|
23
|
+
ZetoLockableLib: zetoLockableLib.target,
|
|
24
|
+
...extra,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function smtLibraries(deps: {
|
|
29
|
+
smtLib: { target: string };
|
|
30
|
+
poseidon2: { target: string };
|
|
31
|
+
poseidon3: { target: string };
|
|
32
|
+
poseidon5?: { target: string };
|
|
33
|
+
poseidon6?: { target: string };
|
|
34
|
+
}): Record<string, string> {
|
|
35
|
+
const libs: Record<string, string> = {
|
|
36
|
+
SmtLib: deps.smtLib.target,
|
|
37
|
+
PoseidonUnit2L: deps.poseidon2.target,
|
|
38
|
+
PoseidonUnit3L: deps.poseidon3.target,
|
|
39
|
+
};
|
|
40
|
+
if (deps.poseidon5) {
|
|
41
|
+
libs.PoseidonUnit5L = deps.poseidon5.target;
|
|
42
|
+
}
|
|
43
|
+
if (deps.poseidon6) {
|
|
44
|
+
libs.PoseidonUnit6L = deps.poseidon6.target;
|
|
45
|
+
}
|
|
46
|
+
return libs;
|
|
47
|
+
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { ethers, ignition } from "hardhat";
|
|
18
18
|
import zetoModule from "../../ignition/modules/zeto_anon";
|
|
19
|
+
import { withZetoLockableLib } from "../lib/zeto_libraries";
|
|
19
20
|
|
|
20
21
|
export async function deployDependencies() {
|
|
21
22
|
const [deployer] = await ethers.getSigners();
|
|
@@ -26,9 +27,11 @@ export async function deployDependencies() {
|
|
|
26
27
|
verifier,
|
|
27
28
|
batchVerifier,
|
|
28
29
|
batchWithdrawVerifier,
|
|
30
|
+
zetoLockableLib,
|
|
29
31
|
} = await ignition.deploy(zetoModule);
|
|
30
32
|
return {
|
|
31
33
|
deployer,
|
|
34
|
+
libraries: withZetoLockableLib(zetoLockableLib),
|
|
32
35
|
args: [
|
|
33
36
|
"Zeto Anon",
|
|
34
37
|
"ZA",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { ethers, ignition } from "hardhat";
|
|
18
18
|
import zetoModule from "../../ignition/modules/zeto_anon_burnable";
|
|
19
|
+
import { withZetoLockableLib } from "../lib/zeto_libraries";
|
|
19
20
|
|
|
20
21
|
export async function deployDependencies() {
|
|
21
22
|
const [deployer] = await ethers.getSigners();
|
|
@@ -28,9 +29,11 @@ export async function deployDependencies() {
|
|
|
28
29
|
batchVerifier,
|
|
29
30
|
batchWithdrawVerifier,
|
|
30
31
|
batchBurnVerifier,
|
|
32
|
+
zetoLockableLib,
|
|
31
33
|
} = await ignition.deploy(zetoModule);
|
|
32
34
|
return {
|
|
33
35
|
deployer,
|
|
36
|
+
libraries: withZetoLockableLib(zetoLockableLib),
|
|
34
37
|
args: [
|
|
35
38
|
"Zeto Anon Burnable",
|
|
36
39
|
"ZAB",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { ethers, ignition } from "hardhat";
|
|
18
18
|
import zetoModule from "../../ignition/modules/zeto_anon_enc";
|
|
19
|
+
import { withZetoLockableLib } from "../lib/zeto_libraries";
|
|
19
20
|
|
|
20
21
|
export async function deployDependencies() {
|
|
21
22
|
const [deployer] = await ethers.getSigners();
|
|
@@ -26,9 +27,11 @@ export async function deployDependencies() {
|
|
|
26
27
|
verifier,
|
|
27
28
|
batchVerifier,
|
|
28
29
|
batchWithdrawVerifier,
|
|
30
|
+
zetoLockableLib,
|
|
29
31
|
} = await ignition.deploy(zetoModule);
|
|
30
32
|
return {
|
|
31
33
|
deployer,
|
|
34
|
+
libraries: withZetoLockableLib(zetoLockableLib),
|
|
32
35
|
args: [
|
|
33
36
|
"Zeto Anon Enc",
|
|
34
37
|
"ZAE",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { ethers, ignition } from "hardhat";
|
|
18
18
|
import zetoModule from "../../ignition/modules/zeto_anon_enc_nullifier";
|
|
19
|
+
import { withZetoLockableLib, smtLibraries } from "../lib/zeto_libraries";
|
|
19
20
|
|
|
20
21
|
export async function deployDependencies() {
|
|
21
22
|
const [deployer] = await ethers.getSigners();
|
|
@@ -31,6 +32,7 @@ export async function deployDependencies() {
|
|
|
31
32
|
smtLib,
|
|
32
33
|
poseidon2,
|
|
33
34
|
poseidon3,
|
|
35
|
+
zetoLockableLib,
|
|
34
36
|
} = await ignition.deploy(zetoModule);
|
|
35
37
|
return {
|
|
36
38
|
deployer,
|
|
@@ -50,10 +52,9 @@ export async function deployDependencies() {
|
|
|
50
52
|
batchBurnVerifier: "0x0000000000000000000000000000000000000000",
|
|
51
53
|
},
|
|
52
54
|
],
|
|
53
|
-
libraries:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
},
|
|
55
|
+
libraries: withZetoLockableLib(
|
|
56
|
+
zetoLockableLib,
|
|
57
|
+
smtLibraries({ smtLib, poseidon2, poseidon3 }),
|
|
58
|
+
),
|
|
58
59
|
};
|
|
59
60
|
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { ethers, ignition } from "hardhat";
|
|
18
18
|
import zetoModule from "../../ignition/modules/zeto_anon_enc_nullifier_kyc";
|
|
19
|
+
import { withZetoLockableLib, smtLibraries } from "../lib/zeto_libraries";
|
|
19
20
|
|
|
20
21
|
export async function deployDependencies() {
|
|
21
22
|
const [deployer] = await ethers.getSigners();
|
|
@@ -29,6 +30,7 @@ export async function deployDependencies() {
|
|
|
29
30
|
smtLib,
|
|
30
31
|
poseidon2,
|
|
31
32
|
poseidon3,
|
|
33
|
+
zetoLockableLib,
|
|
32
34
|
} = await ignition.deploy(zetoModule);
|
|
33
35
|
return {
|
|
34
36
|
deployer,
|
|
@@ -48,10 +50,9 @@ export async function deployDependencies() {
|
|
|
48
50
|
batchBurnVerifier: "0x0000000000000000000000000000000000000000",
|
|
49
51
|
},
|
|
50
52
|
],
|
|
51
|
-
libraries:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
53
|
+
libraries: withZetoLockableLib(
|
|
54
|
+
zetoLockableLib,
|
|
55
|
+
smtLibraries({ smtLib, poseidon2, poseidon3 }),
|
|
56
|
+
),
|
|
56
57
|
};
|
|
57
58
|
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { ethers, ignition } from "hardhat";
|
|
18
18
|
import zetoModule from "../../ignition/modules/zeto_anon_enc_nullifier_non_repudiation";
|
|
19
|
+
import { withZetoLockableLib, smtLibraries } from "../lib/zeto_libraries";
|
|
19
20
|
|
|
20
21
|
export async function deployDependencies() {
|
|
21
22
|
const [deployer] = await ethers.getSigners();
|
|
@@ -29,6 +30,7 @@ export async function deployDependencies() {
|
|
|
29
30
|
smtLib,
|
|
30
31
|
poseidon2,
|
|
31
32
|
poseidon3,
|
|
33
|
+
zetoLockableLib,
|
|
32
34
|
} = await ignition.deploy(zetoModule);
|
|
33
35
|
return {
|
|
34
36
|
deployer,
|
|
@@ -48,10 +50,9 @@ export async function deployDependencies() {
|
|
|
48
50
|
batchBurnVerifier: "0x0000000000000000000000000000000000000000",
|
|
49
51
|
},
|
|
50
52
|
],
|
|
51
|
-
libraries:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
53
|
+
libraries: withZetoLockableLib(
|
|
54
|
+
zetoLockableLib,
|
|
55
|
+
smtLibraries({ smtLib, poseidon2, poseidon3 }),
|
|
56
|
+
),
|
|
56
57
|
};
|
|
57
58
|
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { ethers, ignition } from "hardhat";
|
|
18
18
|
import zetoModule from "../../ignition/modules/zeto_anon_nullifier";
|
|
19
|
+
import { withZetoLockableLib, smtLibraries } from "../lib/zeto_libraries";
|
|
19
20
|
|
|
20
21
|
export async function deployDependencies() {
|
|
21
22
|
const [deployer] = await ethers.getSigners();
|
|
@@ -31,6 +32,7 @@ export async function deployDependencies() {
|
|
|
31
32
|
smtLib,
|
|
32
33
|
poseidon2,
|
|
33
34
|
poseidon3,
|
|
35
|
+
zetoLockableLib,
|
|
34
36
|
} = await ignition.deploy(zetoModule);
|
|
35
37
|
return {
|
|
36
38
|
deployer,
|
|
@@ -50,10 +52,9 @@ export async function deployDependencies() {
|
|
|
50
52
|
batchBurnVerifier: "0x0000000000000000000000000000000000000000",
|
|
51
53
|
},
|
|
52
54
|
],
|
|
53
|
-
libraries:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
},
|
|
55
|
+
libraries: withZetoLockableLib(
|
|
56
|
+
zetoLockableLib,
|
|
57
|
+
smtLibraries({ smtLib, poseidon2, poseidon3 }),
|
|
58
|
+
),
|
|
58
59
|
};
|
|
59
60
|
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { ethers, ignition } from "hardhat";
|
|
18
18
|
import zetoModule from "../../ignition/modules/zeto_anon_nullifier_burnable";
|
|
19
|
+
import { withZetoLockableLib, smtLibraries } from "../lib/zeto_libraries";
|
|
19
20
|
|
|
20
21
|
export async function deployDependencies() {
|
|
21
22
|
const [deployer] = await ethers.getSigners();
|
|
@@ -33,6 +34,7 @@ export async function deployDependencies() {
|
|
|
33
34
|
smtLib,
|
|
34
35
|
poseidon2,
|
|
35
36
|
poseidon3,
|
|
37
|
+
zetoLockableLib,
|
|
36
38
|
} = await ignition.deploy(zetoModule);
|
|
37
39
|
return {
|
|
38
40
|
deployer,
|
|
@@ -52,10 +54,9 @@ export async function deployDependencies() {
|
|
|
52
54
|
batchBurnVerifier: batchBurnVerifier.target,
|
|
53
55
|
},
|
|
54
56
|
],
|
|
55
|
-
libraries:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
},
|
|
57
|
+
libraries: withZetoLockableLib(
|
|
58
|
+
zetoLockableLib,
|
|
59
|
+
smtLibraries({ smtLib, poseidon2, poseidon3 }),
|
|
60
|
+
),
|
|
60
61
|
};
|
|
61
62
|
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { ethers, ignition } from "hardhat";
|
|
18
18
|
import zetoModule from "../../ignition/modules/zeto_anon_nullifier_kyc";
|
|
19
|
+
import { withZetoLockableLib, smtLibraries } from "../lib/zeto_libraries";
|
|
19
20
|
|
|
20
21
|
export async function deployDependencies() {
|
|
21
22
|
const [deployer] = await ethers.getSigners();
|
|
@@ -31,6 +32,7 @@ export async function deployDependencies() {
|
|
|
31
32
|
smtLib,
|
|
32
33
|
poseidon2,
|
|
33
34
|
poseidon3,
|
|
35
|
+
zetoLockableLib,
|
|
34
36
|
} = await ignition.deploy(zetoModule);
|
|
35
37
|
return {
|
|
36
38
|
deployer,
|
|
@@ -50,10 +52,9 @@ export async function deployDependencies() {
|
|
|
50
52
|
batchBurnVerifier: "0x0000000000000000000000000000000000000000",
|
|
51
53
|
},
|
|
52
54
|
],
|
|
53
|
-
libraries:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
},
|
|
55
|
+
libraries: withZetoLockableLib(
|
|
56
|
+
zetoLockableLib,
|
|
57
|
+
smtLibraries({ smtLib, poseidon2, poseidon3 }),
|
|
58
|
+
),
|
|
58
59
|
};
|
|
59
60
|
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { ethers, ignition } from "hardhat";
|
|
18
18
|
import zetoModule from "../../ignition/modules/zeto_anon_nullifier_qurrency";
|
|
19
|
+
import { withZetoLockableLib, smtLibraries } from "../lib/zeto_libraries";
|
|
19
20
|
|
|
20
21
|
export async function deployDependencies() {
|
|
21
22
|
const [deployer] = await ethers.getSigners();
|
|
@@ -33,6 +34,7 @@ export async function deployDependencies() {
|
|
|
33
34
|
poseidon3,
|
|
34
35
|
poseidon5,
|
|
35
36
|
poseidon6,
|
|
37
|
+
zetoLockableLib,
|
|
36
38
|
} = await ignition.deploy(zetoModule);
|
|
37
39
|
return {
|
|
38
40
|
deployer,
|
|
@@ -52,12 +54,9 @@ export async function deployDependencies() {
|
|
|
52
54
|
batchBurnVerifier: "0x0000000000000000000000000000000000000000",
|
|
53
55
|
},
|
|
54
56
|
],
|
|
55
|
-
libraries:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
PoseidonUnit5L: poseidon5.target,
|
|
60
|
-
PoseidonUnit6L: poseidon6.target,
|
|
61
|
-
},
|
|
57
|
+
libraries: withZetoLockableLib(
|
|
58
|
+
zetoLockableLib,
|
|
59
|
+
smtLibraries({ smtLib, poseidon2, poseidon3, poseidon5, poseidon6 }),
|
|
60
|
+
),
|
|
62
61
|
};
|
|
63
62
|
}
|
|
@@ -16,13 +16,15 @@
|
|
|
16
16
|
|
|
17
17
|
import { ethers, ignition } from "hardhat";
|
|
18
18
|
import zetoModule from "../../ignition/modules/zeto_nf_anon";
|
|
19
|
+
import { withZetoLockableLib } from "../lib/zeto_libraries";
|
|
19
20
|
|
|
20
21
|
export async function deployDependencies() {
|
|
21
22
|
const [deployer] = await ethers.getSigners();
|
|
22
23
|
|
|
23
|
-
const { verifier } = await ignition.deploy(zetoModule);
|
|
24
|
+
const { verifier, zetoLockableLib } = await ignition.deploy(zetoModule);
|
|
24
25
|
return {
|
|
25
26
|
deployer,
|
|
27
|
+
libraries: withZetoLockableLib(zetoLockableLib),
|
|
26
28
|
args: [
|
|
27
29
|
"Zeto NF Anon",
|
|
28
30
|
"ZNFA",
|
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
|
|
17
17
|
import { ethers, ignition } from "hardhat";
|
|
18
18
|
import zetoModule from "../../ignition/modules/zeto_nf_anon_nullifier";
|
|
19
|
+
import { withZetoLockableLib, smtLibraries } from "../lib/zeto_libraries";
|
|
19
20
|
|
|
20
21
|
export async function deployDependencies() {
|
|
21
22
|
const [deployer] = await ethers.getSigners();
|
|
22
23
|
|
|
23
|
-
const { verifier, lockVerifier, smtLib, poseidon2, poseidon3 } =
|
|
24
|
+
const { verifier, lockVerifier, smtLib, poseidon2, poseidon3, zetoLockableLib } =
|
|
24
25
|
await ignition.deploy(zetoModule);
|
|
25
26
|
return {
|
|
26
27
|
deployer,
|
|
@@ -40,10 +41,9 @@ export async function deployDependencies() {
|
|
|
40
41
|
batchBurnVerifier: "0x0000000000000000000000000000000000000000",
|
|
41
42
|
},
|
|
42
43
|
],
|
|
43
|
-
libraries:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},
|
|
44
|
+
libraries: withZetoLockableLib(
|
|
45
|
+
zetoLockableLib,
|
|
46
|
+
smtLibraries({ smtLib, poseidon2, poseidon3 }),
|
|
47
|
+
),
|
|
48
48
|
};
|
|
49
49
|
}
|
package/test/factory.ts
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
import { ethers, network } from "hardhat";
|
|
18
18
|
import { Signer } from "ethers";
|
|
19
19
|
import { expect } from "chai";
|
|
20
|
+
import { getLinkedContractFactory } from "../scripts/lib/common";
|
|
21
|
+
import { withZetoLockableLib } from "../scripts/lib/zeto_libraries";
|
|
20
22
|
|
|
21
23
|
describe("(factory) Zeto based fungible token with anonymity without encryption or nullifier", function () {
|
|
22
24
|
let deployer: Signer;
|
|
@@ -292,7 +294,14 @@ describe("(factory) Zeto based fungible token with anonymity without encryption
|
|
|
292
294
|
|
|
293
295
|
// deploy a real Zeto token so that the "implementation" contract can
|
|
294
296
|
// pass the code length check in the ERC1967Proxy contract
|
|
295
|
-
const
|
|
297
|
+
const ZetoLockableLib = await ethers.getContractFactory("ZetoLockableLib");
|
|
298
|
+
const zetoLockableLib = await ZetoLockableLib.deploy();
|
|
299
|
+
await zetoLockableLib.waitForDeployment();
|
|
300
|
+
|
|
301
|
+
const Zeto = await getLinkedContractFactory(
|
|
302
|
+
"Zeto_Anon",
|
|
303
|
+
withZetoLockableLib(zetoLockableLib),
|
|
304
|
+
);
|
|
296
305
|
const zeto = await Zeto.deploy();
|
|
297
306
|
await zeto.waitForDeployment();
|
|
298
307
|
|
package/test/lib/deploy.ts
CHANGED
|
@@ -12,8 +12,10 @@ import {
|
|
|
12
12
|
import fungibilities from "../../scripts/tokens.json";
|
|
13
13
|
import { logger } from "./utils";
|
|
14
14
|
import { ethers } from "hardhat";
|
|
15
|
+
import { assertEip170Compliant } from "./eip170";
|
|
15
16
|
|
|
16
17
|
export async function deployZeto(tokenName: string) {
|
|
18
|
+
await assertEip170Compliant(tokenName);
|
|
17
19
|
let zeto, erc20, deployer;
|
|
18
20
|
|
|
19
21
|
// for testing with public chains, skip deployment if
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { artifacts } from "hardhat";
|
|
2
|
+
import {
|
|
3
|
+
EIP170_BYTE_LIMIT,
|
|
4
|
+
EIP170_EXEMPT_TOKEN_SET,
|
|
5
|
+
} from "../../config/eip170";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Assert a token implementation fits EIP-170 before deploy when it is not exempt.
|
|
9
|
+
* Hardhat Network runs with allowUnlimitedContractSize enabled (see hardhat.config.ts);
|
|
10
|
+
* exempt tokens may exceed the limit.
|
|
11
|
+
*/
|
|
12
|
+
export async function assertEip170Compliant(tokenName: string): Promise<void> {
|
|
13
|
+
if (EIP170_EXEMPT_TOKEN_SET.has(tokenName)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const artifact = await artifacts.readArtifact(tokenName);
|
|
17
|
+
const deployedBytes = (artifact.deployedBytecode.length - 2) / 2;
|
|
18
|
+
if (deployedBytes > EIP170_BYTE_LIMIT) {
|
|
19
|
+
throw new Error(
|
|
20
|
+
`${tokenName} deployed bytecode is ${deployedBytes} bytes, exceeding EIP-170 limit ${EIP170_BYTE_LIMIT}`,
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
}
|