@openzeppelin/compact-contracts 0.4.0-alpha.3 → 0.4.0-alpha.5
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/access/AccessControl.compact +1 -1
- package/access/Ownable.compact +1 -1
- package/access/ShieldedAccessControl.compact +1 -1
- package/access/ZOwnablePK.compact +1 -1
- package/crypto/EcdhMask.compact +1 -1
- package/crypto/Ecdsa.compact +1 -1
- package/crypto/Eip712.compact +1 -1
- package/crypto/ElGamal.compact +1 -1
- package/multisig/EcdsaSignerManager.compact +9 -7
- package/multisig/ForwarderPrivate.compact +1 -1
- package/multisig/ForwarderShielded.compact +14 -5
- package/multisig/ForwarderUnshielded.compact +1 -1
- package/multisig/ProposalManager.compact +1 -1
- package/multisig/ShieldedTreasury.compact +1 -1
- package/multisig/ShieldedTreasuryStateless.compact +1 -1
- package/multisig/Signer.compact +1 -1
- package/multisig/UnshieldedTreasury.compact +5 -3
- package/multisig/examples/ForwarderPrivateExample.compact +1 -1
- package/multisig/examples/ForwarderShieldedExample.compact +8 -5
- package/multisig/examples/ForwarderUnshieldedExample.compact +1 -1
- package/multisig/examples/NativeShieldedTokenIssuerExample.compact +29 -7
- package/multisig/examples/ShieldedMultiSigV2Example.compact +2 -2
- package/multisig/presets/NativeShieldedTokenIssuer.compact +278 -123
- package/multisig/presets/ShieldedMultiSigV2.compact +16 -7
- package/package.json +6 -4
- package/security/Allowlist.compact +1 -1
- package/security/Blocklist.compact +1 -1
- package/security/Initializable.compact +1 -1
- package/security/Pausable.compact +1 -1
- package/token/ConfidentialFungibleToken.compact +17 -1
- package/token/FungibleToken.compact +1 -1
- package/token/MultiToken.compact +1 -1
- package/token/NativeShieldedToken.compact +2 -2
- package/token/NativeShieldedTokenCore.compact +11 -18
- package/token/NativeShieldedTokenFamily.compact +2 -2
- package/token/NonFungibleToken.compact +1 -1
- package/token/extensions/ConfidentialFungibleTokenPublicSupply.compact +1 -1
- package/token/extensions/NativeShieldedTokenDerivedNonce.compact +1 -1
- package/utils/EvmAbi.compact +1 -1
- package/utils/Utils.compact +1 -1
package/access/Ownable.compact
CHANGED
package/crypto/EcdhMask.compact
CHANGED
package/crypto/Ecdsa.compact
CHANGED
package/crypto/Eip712.compact
CHANGED
package/crypto/ElGamal.compact
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Compact Contracts v0.4.0-alpha.
|
|
2
|
+
// OpenZeppelin Compact Contracts v0.4.0-alpha.5 (multisig/EcdsaSignerManager.compact)
|
|
3
3
|
|
|
4
4
|
pragma language_version >= 0.26.0;
|
|
5
5
|
|
|
@@ -77,13 +77,14 @@ module EcdsaSignerManager {
|
|
|
77
77
|
* - Can only be called once.
|
|
78
78
|
* - `instanceSalt` should be cryptographically random.
|
|
79
79
|
* - `signerCommitments` must not contain duplicates.
|
|
80
|
-
* - `
|
|
81
|
-
*
|
|
82
|
-
*
|
|
80
|
+
* - `n` must be at least 2, the number of distinct signers `assertApprovals`
|
|
81
|
+
* verifies. A smaller set can never satisfy it.
|
|
82
|
+
* - `threshold` must be 2, the number of approvals `assertApprovals`
|
|
83
|
+
* verifies. Any other value would misreport what the circuit enforces.
|
|
83
84
|
*
|
|
84
85
|
* @param {Bytes<32>} instanceSalt - Per-deployment salt for commitment derivation.
|
|
85
86
|
* @param {Vector<n, Bytes<32>>} signerCommitments - Hashed signer identities.
|
|
86
|
-
* @param {Uint<8>} threshold -
|
|
87
|
+
* @param {Uint<8>} threshold - Approvals required. Must be 2.
|
|
87
88
|
* @returns {[]} Empty tuple.
|
|
88
89
|
*/
|
|
89
90
|
export circuit initialize<#n>(
|
|
@@ -93,11 +94,12 @@ module EcdsaSignerManager {
|
|
|
93
94
|
): [] {
|
|
94
95
|
assert(Signer_getSignerCount() == 0, "EcdsaSignerManager: signers already registered");
|
|
95
96
|
_instanceSalt = disclose(instanceSalt);
|
|
96
|
-
assert(threshold
|
|
97
|
+
assert(threshold == 2, "EcdsaSignerManager: threshold must be 2 (assertApprovals verifies 2 signatures)");
|
|
97
98
|
|
|
98
99
|
for (const commitment of signerCommitments) {
|
|
99
100
|
Signer__addSigner(commitment);
|
|
100
101
|
}
|
|
102
|
+
assert(Signer_getSignerCount() >= 2, "EcdsaSignerManager: fewer than 2 signers (assertApprovals verifies 2 signatures)");
|
|
101
103
|
Signer__changeThreshold(threshold);
|
|
102
104
|
}
|
|
103
105
|
|
|
@@ -140,7 +142,7 @@ module EcdsaSignerManager {
|
|
|
140
142
|
* same signer.
|
|
141
143
|
*
|
|
142
144
|
* @dev Both entries are asserted, so the count handed to the threshold check
|
|
143
|
-
* is always 2
|
|
145
|
+
* is always 2, matching the only threshold `initialize` accepts.
|
|
144
146
|
*
|
|
145
147
|
* @constraints k=17, rows=64916 (zkir-v3)
|
|
146
148
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Compact Contracts v0.4.0-alpha.
|
|
2
|
+
// OpenZeppelin Compact Contracts v0.4.0-alpha.5 (multisig/ForwarderShielded.compact)
|
|
3
3
|
|
|
4
4
|
pragma language_version >= 0.26.0;
|
|
5
5
|
|
|
@@ -41,6 +41,11 @@ pragma language_version >= 0.26.0;
|
|
|
41
41
|
* coins. Forwarding to a key no one controls strands every deposit
|
|
42
42
|
* permanently. The zero-key guard rejects only the all-zero key, not an
|
|
43
43
|
* otherwise-unspendable one.
|
|
44
|
+
*
|
|
45
|
+
* @notice The depositor must encrypt the forwarded output to the parent's
|
|
46
|
+
* encryption public key, obtained off-chain. The ledger cannot check that
|
|
47
|
+
* key against `_parent`, so a wrong or missing key leaves the coin
|
|
48
|
+
* spendable by the parent but invisible to its wallet.
|
|
44
49
|
*/
|
|
45
50
|
module ForwarderShielded {
|
|
46
51
|
import CompactStandardLibrary;
|
|
@@ -103,20 +108,24 @@ module ForwarderShielded {
|
|
|
103
108
|
* `sendImmediateShielded` to the stored parent recipient (always the
|
|
104
109
|
* `left` / coin-public-key arm today).
|
|
105
110
|
*
|
|
106
|
-
* @constraints k=15, rows=
|
|
111
|
+
* @constraints k=15, rows=23197
|
|
107
112
|
*
|
|
108
113
|
* Requirements:
|
|
109
114
|
*
|
|
110
115
|
* - Contract must be initialized.
|
|
116
|
+
* - The forwarded output must be encrypted to the parent's encryption
|
|
117
|
+
* public key (see the module header). If unsure, hand the returned
|
|
118
|
+
* `ShieldedSendResult` to the parent so it can recover the coin.
|
|
111
119
|
*
|
|
112
120
|
* @param {ShieldedCoinInfo} coin - The incoming shielded coin.
|
|
113
121
|
*
|
|
114
|
-
* @returns {
|
|
122
|
+
* @returns {ShieldedSendResult} The coin sent to the parent, with no change:
|
|
123
|
+
* the whole value is forwarded.
|
|
115
124
|
*/
|
|
116
|
-
export circuit _deposit(coin: ShieldedCoinInfo):
|
|
125
|
+
export circuit _deposit(coin: ShieldedCoinInfo): ShieldedSendResult {
|
|
117
126
|
assertInitialized();
|
|
118
127
|
receiveShielded(disclose(coin));
|
|
119
|
-
sendImmediateShielded(disclose(coin), _parent, disclose(coin.value));
|
|
128
|
+
return sendImmediateShielded(disclose(coin), _parent, disclose(coin.value));
|
|
120
129
|
}
|
|
121
130
|
|
|
122
131
|
// ─── Init guards ────────────────────────────────────────────────
|
package/multisig/Signer.compact
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Compact Contracts v0.4.0-alpha.
|
|
2
|
+
// OpenZeppelin Compact Contracts v0.4.0-alpha.5 (multisig/UnshieldedTreasury.compact)
|
|
3
3
|
|
|
4
4
|
pragma language_version >= 0.26.0;
|
|
5
5
|
|
|
@@ -90,8 +90,7 @@ module UnshieldedTreasury {
|
|
|
90
90
|
// ─── Send ───────────────────────────────────────────────────────
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
|
-
* @description Sends unshielded tokens from the treasury.
|
|
94
|
-
* are permitted and are value-preserving no-ops.
|
|
93
|
+
* @description Sends unshielded tokens from the treasury.
|
|
95
94
|
*
|
|
96
95
|
* @warning Recipients are not validated. An unspendable recipient (such as a
|
|
97
96
|
* zero address) is accepted and permanently removes the funds from the
|
|
@@ -111,6 +110,7 @@ module UnshieldedTreasury {
|
|
|
111
110
|
*
|
|
112
111
|
* Requirements:
|
|
113
112
|
*
|
|
113
|
+
* - The amount must be non-zero. The ledger rejects zero-value outputs.
|
|
114
114
|
* - The treasury must hold sufficient balance for the given token color.
|
|
115
115
|
*
|
|
116
116
|
* @param {Either<ContractAddress, UserAddress>} recipient - The recipient address.
|
|
@@ -124,6 +124,8 @@ module UnshieldedTreasury {
|
|
|
124
124
|
color: Bytes<32>,
|
|
125
125
|
amount: Uint<128>
|
|
126
126
|
): [] {
|
|
127
|
+
assert(amount != 0, "UnshieldedTreasury: zero amount");
|
|
128
|
+
|
|
127
129
|
const bal = getTokenBalance(color);
|
|
128
130
|
assert(bal >= amount, "UnshieldedTreasury: insufficient balance");
|
|
129
131
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Compact Contracts v0.4.0-alpha.
|
|
2
|
+
// OpenZeppelin Compact Contracts v0.4.0-alpha.5 (multisig/examples/ForwarderPrivateExample.compact)
|
|
3
3
|
|
|
4
4
|
pragma language_version >= 0.26.0;
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Compact Contracts v0.4.0-alpha.
|
|
2
|
+
// OpenZeppelin Compact Contracts v0.4.0-alpha.5 (multisig/examples/ForwarderShieldedExample.compact)
|
|
3
3
|
|
|
4
4
|
pragma language_version >= 0.26.0;
|
|
5
5
|
|
|
@@ -24,7 +24,7 @@ pragma language_version >= 0.26.0;
|
|
|
24
24
|
import CompactStandardLibrary;
|
|
25
25
|
import "../ForwarderShielded" prefix Forwarder_;
|
|
26
26
|
|
|
27
|
-
export { ZswapCoinPublicKey, ContractAddress, ShieldedCoinInfo, Either };
|
|
27
|
+
export { ZswapCoinPublicKey, ContractAddress, ShieldedCoinInfo, ShieldedSendResult, Maybe, Either };
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* @description Deploys the forwarder bound to a specific parent
|
|
@@ -42,12 +42,15 @@ constructor(parent: ZswapCoinPublicKey) {
|
|
|
42
42
|
* the configured parent. The coin is claimed via `receiveShielded` and
|
|
43
43
|
* immediately re-sent via `sendImmediateShielded`.
|
|
44
44
|
*
|
|
45
|
+
* The depositor must encrypt the forwarded output to the parent's
|
|
46
|
+
* encryption public key (see the `ForwarderShielded` header).
|
|
47
|
+
*
|
|
45
48
|
* @param {ShieldedCoinInfo} coin - The incoming shielded coin.
|
|
46
49
|
*
|
|
47
|
-
* @returns {
|
|
50
|
+
* @returns {ShieldedSendResult} The coin sent to the parent, with no change.
|
|
48
51
|
*/
|
|
49
|
-
export circuit deposit(coin: ShieldedCoinInfo):
|
|
50
|
-
Forwarder__deposit(coin);
|
|
52
|
+
export circuit deposit(coin: ShieldedCoinInfo): ShieldedSendResult {
|
|
53
|
+
return Forwarder__deposit(coin);
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Compact Contracts v0.4.0-alpha.
|
|
2
|
+
// OpenZeppelin Compact Contracts v0.4.0-alpha.5 (multisig/examples/ForwarderUnshieldedExample.compact)
|
|
3
3
|
|
|
4
4
|
pragma language_version >= 0.26.0;
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Compact Contracts v0.4.0-alpha.
|
|
2
|
+
// OpenZeppelin Compact Contracts v0.4.0-alpha.5 (multisig/examples/NativeShieldedTokenIssuerExample.compact)
|
|
3
3
|
|
|
4
4
|
pragma language_version >= 0.26.0;
|
|
5
5
|
|
|
@@ -7,10 +7,14 @@ pragma language_version >= 0.26.0;
|
|
|
7
7
|
* @title NativeShieldedTokenIssuerExample
|
|
8
8
|
* @description Deployable reference contract for the `NativeShieldedTokenIssuer`
|
|
9
9
|
* preset: a native shielded token whose supply enters only through an
|
|
10
|
-
* ECDSA-authorized mint
|
|
10
|
+
* ECDSA-authorized mint, to a holder (`mint`) or to the contract itself
|
|
11
|
+
* (`mintToSelf`), and leaves only through an ECDSA-authorized burn, of a
|
|
12
|
+
* holder's coin (`burn`) or of one the contract holds (`burnFromSelf`).
|
|
11
13
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
+
* Coins minted to holders are ordinary Zswap coins: holders transfer them
|
|
15
|
+
* through Zswap without the issuer's involvement and redeem by paying one
|
|
16
|
+
* into a `burn` tx. Only contract-held coins are locked. No send circuit
|
|
17
|
+
* exists, so they leave through `burnFromSelf` alone.
|
|
14
18
|
*/
|
|
15
19
|
|
|
16
20
|
import CompactStandardLibrary;
|
|
@@ -94,20 +98,38 @@ export pure circuit _calculateSignerId(
|
|
|
94
98
|
|
|
95
99
|
export circuit mint(
|
|
96
100
|
amount: Uint<64>,
|
|
97
|
-
recipient:
|
|
101
|
+
recipient: ZswapCoinPublicKey,
|
|
98
102
|
pubkeys: Vector<2, Secp256k1Point>,
|
|
99
103
|
signatures: Vector<2, Secp256k1EcdsaSignature>
|
|
100
104
|
): ShieldedCoinInfo {
|
|
101
105
|
return NativeShieldedTokenIssuer_mint(amount, recipient, pubkeys, signatures);
|
|
102
106
|
}
|
|
103
107
|
|
|
108
|
+
export circuit mintToSelf(
|
|
109
|
+
amount: Uint<64>,
|
|
110
|
+
pubkeys: Vector<2, Secp256k1Point>,
|
|
111
|
+
signatures: Vector<2, Secp256k1EcdsaSignature>
|
|
112
|
+
): ShieldedCoinInfo {
|
|
113
|
+
return NativeShieldedTokenIssuer_mintToSelf(amount, pubkeys, signatures);
|
|
114
|
+
}
|
|
115
|
+
|
|
104
116
|
export circuit burn(
|
|
117
|
+
coin: ShieldedCoinInfo,
|
|
118
|
+
amount: Uint<128>,
|
|
119
|
+
refundTo: ZswapCoinPublicKey,
|
|
120
|
+
pubkeys: Vector<2, Secp256k1Point>,
|
|
121
|
+
signatures: Vector<2, Secp256k1EcdsaSignature>
|
|
122
|
+
): Maybe<ShieldedCoinInfo> {
|
|
123
|
+
return NativeShieldedTokenIssuer_burn(coin, amount, refundTo, pubkeys, signatures);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export circuit burnFromSelf(
|
|
105
127
|
coin: QualifiedShieldedCoinInfo,
|
|
106
|
-
amount: Uint<
|
|
128
|
+
amount: Uint<128>,
|
|
107
129
|
pubkeys: Vector<2, Secp256k1Point>,
|
|
108
130
|
signatures: Vector<2, Secp256k1EcdsaSignature>
|
|
109
131
|
): Maybe<ShieldedCoinInfo> {
|
|
110
|
-
return
|
|
132
|
+
return NativeShieldedTokenIssuer_burnFromSelf(coin, amount, pubkeys, signatures);
|
|
111
133
|
}
|
|
112
134
|
|
|
113
135
|
export circuit getNonce(): Uint<64> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Compact Contracts v0.4.0-alpha.
|
|
2
|
+
// OpenZeppelin Compact Contracts v0.4.0-alpha.5 (multisig/examples/ShieldedMultiSigV2Example.compact)
|
|
3
3
|
|
|
4
4
|
pragma language_version >= 0.26.0;
|
|
5
5
|
|
|
@@ -29,7 +29,7 @@ export { _domainSeparator };
|
|
|
29
29
|
*
|
|
30
30
|
* @param {Bytes<32>} instanceSalt - Random salt for commitment derivation.
|
|
31
31
|
* @param {Vector<3, Bytes<32>>} signerCommitments - Hashed signer identities.
|
|
32
|
-
* @param {Uint<8>} thresh -
|
|
32
|
+
* @param {Uint<8>} thresh - Approvals required. Must be 2.
|
|
33
33
|
*/
|
|
34
34
|
constructor(
|
|
35
35
|
instanceSalt: Bytes<32>,
|