@openzeppelin/compact-contracts 0.4.0-alpha.2 → 0.4.0-alpha.3
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 +44 -3
- package/multisig/EcdsaSignerManager.compact +1 -1
- package/multisig/ForwarderPrivate.compact +1 -1
- package/multisig/ForwarderShielded.compact +1 -1
- 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 +1 -1
- package/multisig/examples/ForwarderPrivateExample.compact +1 -1
- package/multisig/examples/ForwarderShieldedExample.compact +1 -1
- package/multisig/examples/ForwarderUnshieldedExample.compact +1 -1
- package/multisig/examples/NativeShieldedTokenIssuerExample.compact +1 -1
- package/multisig/examples/ShieldedMultiSigV2Example.compact +1 -1
- package/multisig/presets/NativeShieldedTokenIssuer.compact +18 -3
- package/multisig/presets/ShieldedMultiSigV2.compact +1 -1
- package/package.json +1 -1
- 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 +268 -69
- package/token/FungibleToken.compact +1 -1
- package/token/MultiToken.compact +1 -1
- package/token/NativeShieldedToken.compact +59 -10
- package/token/NativeShieldedTokenCore.compact +41 -9
- package/token/NativeShieldedTokenFamily.compact +60 -10
- package/token/NonFungibleToken.compact +56 -12
- package/token/extensions/ConfidentialFungibleTokenPublicSupply.compact +1 -1
- package/token/extensions/NativeShieldedTokenDerivedNonce.compact +1 -1
- package/token/extensions/NativeShieldedTokenFamilyPublicSupply.compact +2 -2
- package/token/extensions/NativeShieldedTokenPublicSupply.compact +2 -2
- package/utils/EvmAbi.compact +1 -1
- package/utils/Utils.compact +11 -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.3 (crypto/ElGamal.compact)
|
|
3
3
|
|
|
4
4
|
pragma language_version >= 0.26.0;
|
|
5
5
|
|
|
@@ -38,6 +38,13 @@ pragma language_version >= 0.26.0;
|
|
|
38
38
|
* cast reduces modulo the subgroup order, so casting at a call site would
|
|
39
39
|
* silently accept an out-of-range scalar the typed parameter rejects.
|
|
40
40
|
*
|
|
41
|
+
* @dev Domain separation. `persistentHash<Vector<N, Bytes<32>>>` is NOT
|
|
42
|
+
* domain-separating on its own. Two circuits hashing the same arity and
|
|
43
|
+
* element type share one hash domain, and the hash cannot tell which slot was
|
|
44
|
+
* "meant" as a tag. `secretToScalar` therefore prefixes a fixed constant, and
|
|
45
|
+
* that constant is placed FIRST so no call to `expandRandomness` (whose two
|
|
46
|
+
* slots are both caller-supplied) can reproduce the tuple by ordinary use.
|
|
47
|
+
*
|
|
41
48
|
* @dev TRUST ASSUMPTION — subgroup membership. This is the module's most
|
|
42
49
|
* load-bearing assumption. Every `JubjubPoint` reaching a curve operation is
|
|
43
50
|
* assumed to be in the Jubjub prime-order subgroup, including points supplied by
|
|
@@ -105,11 +112,34 @@ module ElGamal {
|
|
|
105
112
|
* @description Maps a 32-byte secret to a valid Jubjub scalar. See the
|
|
106
113
|
* module-level hash-to-scalar note for why `degradeToTransient` is required.
|
|
107
114
|
*
|
|
115
|
+
* @dev Domain separation here is load-bearing, not cosmetic. This output is
|
|
116
|
+
* the private key protecting every ciphertext held under an account. Public
|
|
117
|
+
* account identifiers derived from `Utils.computeAccountId`, for example,
|
|
118
|
+
* are computed as `persistentHash([secretKey])`, and that identifier
|
|
119
|
+
* is stored in the clear as a ledger map key. Untagged, this circuit
|
|
120
|
+
* would compute that same hash, so a secret used in both roles would
|
|
121
|
+
* have its encryption key recoverable from a published identifier by applying
|
|
122
|
+
* `degradeToTransient`. The tag makes the two derivations unrelated, so a
|
|
123
|
+
* wallet MAY safely derive its account secret and its encryption secret from
|
|
124
|
+
* common key material.
|
|
125
|
+
*
|
|
126
|
+
* @dev The tag is FIRST, deliberately. `expandRandomness` hashes
|
|
127
|
+
* `[seed, tag]` with both slots caller-supplied, so tagging this circuit as
|
|
128
|
+
* `[secret, tag]` would make `secretToScalar(x)` identical to
|
|
129
|
+
* `expandRandomness(x, <this tag>)` reachable by passing this domain string
|
|
130
|
+
* to the parameter that exists to receive domain strings. Leading with the
|
|
131
|
+
* tag means reproducing this output through `expandRandomness` would require
|
|
132
|
+
* passing the domain constant as the *seed*. Do not normalise the orderings.
|
|
133
|
+
*
|
|
108
134
|
* @param secret - The 32-byte secret to map.
|
|
109
135
|
* @return A valid Jubjub scalar.
|
|
110
136
|
*/
|
|
111
137
|
export pure circuit secretToScalar(secret: Bytes<32>): JubjubScalar {
|
|
112
|
-
return degradeToTransient(
|
|
138
|
+
return degradeToTransient(
|
|
139
|
+
persistentHash<Vector<2, Bytes<32>>>(
|
|
140
|
+
[pad(32, "ElGamal:secretToScalar"), secret]
|
|
141
|
+
)
|
|
142
|
+
) as JubjubScalar;
|
|
113
143
|
}
|
|
114
144
|
|
|
115
145
|
/**
|
|
@@ -419,6 +449,17 @@ module ElGamal {
|
|
|
419
449
|
* wrong plaintext fails the decryption check. Lifted special case of
|
|
420
450
|
* `assertDecryptsToPoint` with the message point `g^claimedValue`.
|
|
421
451
|
*
|
|
452
|
+
* @notice `claimedValue` is the widest `Uint` Compact offers, so this parameter
|
|
453
|
+
* never bounds a caller. A narrower value costs proportionally fewer rows: the
|
|
454
|
+
* range constraint belongs to where the value is declared, not to this
|
|
455
|
+
* signature.
|
|
456
|
+
*
|
|
457
|
+
* @warning The claim domain must stay below the Jubjub subgroup order `l`:
|
|
458
|
+
* verification compares `g^claimedValue`, so two claims congruent mod `l` are
|
|
459
|
+
* indistinguishable. `Uint<248>` clears `l` (~2^251.86) by under 4 bits, and
|
|
460
|
+
* that width is set by Compact's cap rather than by this bound. 251 is the
|
|
461
|
+
* widest sound `Uint` if the cap ever rises.
|
|
462
|
+
*
|
|
422
463
|
* Requirements:
|
|
423
464
|
*
|
|
424
465
|
* - `ek` is the secret for `pk`.
|
|
@@ -433,7 +474,7 @@ module ElGamal {
|
|
|
433
474
|
ct: Ciphertext,
|
|
434
475
|
pk: JubjubPoint,
|
|
435
476
|
ek: Bytes<32>,
|
|
436
|
-
claimedValue: Uint<
|
|
477
|
+
claimedValue: Uint<248>
|
|
437
478
|
): [] {
|
|
438
479
|
assertDecryptsToPoint(ct, pk, ek, ecMulGenerator(claimedValue as JubjubScalar));
|
|
439
480
|
}
|
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.3 (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.3 (multisig/examples/ForwarderShieldedExample.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.3 (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.3 (multisig/examples/NativeShieldedTokenIssuerExample.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.3 (multisig/examples/ShieldedMultiSigV2Example.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.3 (multisig/presets/NativeShieldedTokenIssuer.compact)
|
|
3
3
|
|
|
4
4
|
pragma language_version >= 0.26.0;
|
|
5
5
|
|
|
@@ -348,7 +348,7 @@ module NativeShieldedTokenIssuer {
|
|
|
348
348
|
* @notice The returned coin info is the only copy available to the
|
|
349
349
|
* recipient; deliver it out of band.
|
|
350
350
|
*
|
|
351
|
-
* @constraints k=17, rows=
|
|
351
|
+
* @constraints k=17, rows=105173 (zkir-v3)
|
|
352
352
|
*
|
|
353
353
|
* Requirements:
|
|
354
354
|
*
|
|
@@ -357,6 +357,7 @@ module NativeShieldedTokenIssuer {
|
|
|
357
357
|
* - Signers must not be duplicates.
|
|
358
358
|
* - Threshold must be met.
|
|
359
359
|
* - `recipient` is not zero.
|
|
360
|
+
* - A contract `recipient` is this contract's own address.
|
|
360
361
|
*
|
|
361
362
|
* @param {Uint<64>} amount - The token amount to mint.
|
|
362
363
|
* @param {Either<ZswapCoinPublicKey, ContractAddress>} recipient - The address to receive the minted tokens.
|
|
@@ -396,7 +397,21 @@ module NativeShieldedTokenIssuer {
|
|
|
396
397
|
|
|
397
398
|
EcdsaSignerManager_assertApprovals(msgHash, pubkeys, signatures);
|
|
398
399
|
|
|
399
|
-
|
|
400
|
+
// `NST__mint` takes a coin public key only; the contract arm is limited to
|
|
401
|
+
// this contract, since a mint to any other contract leaves an unclaimed
|
|
402
|
+
// output.
|
|
403
|
+
// The recipient is public (it is already in the signed digest), so the
|
|
404
|
+
// arm may gate which mint runs.
|
|
405
|
+
const target = disclose(canonRecipient);
|
|
406
|
+
const self = kernel.self();
|
|
407
|
+
assert(target.is_left || target.right == self,
|
|
408
|
+
"NativeShieldedToken: recipient contract must be self");
|
|
409
|
+
const nonce = NSTDerivedNonce__deriveNonce();
|
|
410
|
+
if (target.is_left) {
|
|
411
|
+
return NST__mint(target.left, amount, nonce);
|
|
412
|
+
} else {
|
|
413
|
+
return NST__mintToSelf(amount, nonce);
|
|
414
|
+
}
|
|
400
415
|
}
|
|
401
416
|
|
|
402
417
|
/**
|
package/package.json
CHANGED