@openzeppelin/compact-contracts 0.3.0-alpha.2 → 0.3.0-rc.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 (36) hide show
  1. package/access/AccessControl.compact +1 -1
  2. package/access/Ownable.compact +1 -1
  3. package/access/ShieldedAccessControl.compact +1 -1
  4. package/access/ZOwnablePK.compact +1 -1
  5. package/crypto/EcdhMask.compact +1 -1
  6. package/crypto/ElGamal.compact +44 -3
  7. package/multisig/ForwarderPrivate.compact +1 -1
  8. package/multisig/ForwarderShielded.compact +1 -1
  9. package/multisig/ForwarderUnshielded.compact +1 -1
  10. package/multisig/ProposalManager.compact +1 -1
  11. package/multisig/ShieldedTreasury.compact +1 -1
  12. package/multisig/ShieldedTreasuryStateless.compact +1 -1
  13. package/multisig/Signer.compact +1 -1
  14. package/multisig/UnshieldedTreasury.compact +1 -1
  15. package/multisig/presets/ShieldedMultiSig.compact +1 -1
  16. package/multisig/presets/ShieldedMultiSigV2.compact +1 -1
  17. package/multisig/presets/forwarder/ForwarderPrivate.compact +1 -1
  18. package/multisig/presets/forwarder/ForwarderShielded.compact +1 -1
  19. package/multisig/presets/forwarder/ForwarderUnshielded.compact +1 -1
  20. package/package.json +1 -1
  21. package/security/Allowlist.compact +1 -1
  22. package/security/Blocklist.compact +1 -1
  23. package/security/Initializable.compact +1 -1
  24. package/security/Pausable.compact +1 -1
  25. package/token/ConfidentialFungibleToken.compact +253 -67
  26. package/token/FungibleToken.compact +1 -1
  27. package/token/MultiToken.compact +1 -1
  28. package/token/NativeShieldedToken.compact +59 -10
  29. package/token/NativeShieldedTokenCore.compact +41 -9
  30. package/token/NativeShieldedTokenFamily.compact +60 -10
  31. package/token/NonFungibleToken.compact +63 -19
  32. package/token/extensions/ConfidentialFungibleTokenPublicSupply.compact +1 -1
  33. package/token/extensions/NativeShieldedTokenDerivedNonce.compact +1 -1
  34. package/token/extensions/NativeShieldedTokenFamilyPublicSupply.compact +2 -2
  35. package/token/extensions/NativeShieldedTokenPublicSupply.compact +2 -2
  36. package/utils/Utils.compact +11 -1
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (access/AccessControl.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (access/AccessControl.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (access/Ownable.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (access/Ownable.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (access/ShieldedAccessControl.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (access/ShieldedAccessControl.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (access/ZOwnablePK.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (access/ZOwnablePK.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (crypto/EcdhMask.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (crypto/EcdhMask.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (crypto/ElGamal.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (crypto/ElGamal.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
@@ -34,6 +34,13 @@ pragma language_version >= 0.23.0;
34
34
  * scalar. Feeding a raw `persistentHash` output into `ecMulGenerator` would
35
35
  * occasionally exceed the Jubjub scalar field order and fault at runtime.
36
36
  *
37
+ * @dev Domain separation. `persistentHash<Vector<N, Bytes<32>>>` is NOT
38
+ * domain-separating on its own. Two circuits hashing the same arity and
39
+ * element type share one hash domain, and the hash cannot tell which slot was
40
+ * "meant" as a tag. `secretToScalar` therefore prefixes a fixed constant, and
41
+ * that constant is placed FIRST so no call to `expandRandomness` (whose two
42
+ * slots are both caller-supplied) can reproduce the tuple by ordinary use.
43
+ *
37
44
  * @dev TRUST ASSUMPTION — subgroup membership. This is the module's most
38
45
  * load-bearing assumption. Every `JubjubPoint` reaching a curve operation is
39
46
  * assumed to be in the Jubjub prime-order subgroup, including points supplied by
@@ -102,11 +109,34 @@ module ElGamal {
102
109
  * @description Maps a 32-byte secret to a valid Jubjub scalar. See the
103
110
  * module-level hash-to-scalar note for why `degradeToTransient` is required.
104
111
  *
112
+ * @dev Domain separation here is load-bearing, not cosmetic. This output is
113
+ * the private key protecting every ciphertext held under an account. Public
114
+ * account identifiers derived from `Utils.computeAccountId`, for example,
115
+ * are computed as `persistentHash([secretKey])`, and that identifier
116
+ * is stored in the clear as a ledger map key. Untagged, this circuit
117
+ * would compute that same hash, so a secret used in both roles would
118
+ * have its encryption key recoverable from a published identifier by applying
119
+ * `degradeToTransient`. The tag makes the two derivations unrelated, so a
120
+ * wallet MAY safely derive its account secret and its encryption secret from
121
+ * common key material.
122
+ *
123
+ * @dev The tag is FIRST, deliberately. `expandRandomness` hashes
124
+ * `[seed, tag]` with both slots caller-supplied, so tagging this circuit as
125
+ * `[secret, tag]` would make `secretToScalar(x)` identical to
126
+ * `expandRandomness(x, <this tag>)` reachable by passing this domain string
127
+ * to the parameter that exists to receive domain strings. Leading with the
128
+ * tag means reproducing this output through `expandRandomness` would require
129
+ * passing the domain constant as the *seed*. Do not normalise the orderings.
130
+ *
105
131
  * @param secret - The 32-byte secret to map.
106
132
  * @return A Field guaranteed to be a valid Jubjub scalar.
107
133
  */
108
134
  export pure circuit secretToScalar(secret: Bytes<32>): Field {
109
- return degradeToTransient(persistentHash<Vector<1, Bytes<32>>>([secret]));
135
+ return degradeToTransient(
136
+ persistentHash<Vector<2, Bytes<32>>>(
137
+ [pad(32, "ElGamal:secretToScalar"), secret]
138
+ )
139
+ );
110
140
  }
111
141
 
112
142
  /**
@@ -452,6 +482,17 @@ module ElGamal {
452
482
  * wrong plaintext fails the decryption check. Lifted special case of
453
483
  * `assertDecryptsToPoint` with the message point `g^claimedValue`.
454
484
  *
485
+ * @notice `claimedValue` is the widest `Uint` Compact offers, so this parameter
486
+ * never bounds a caller. A narrower value costs proportionally fewer rows: the
487
+ * range constraint belongs to where the value is declared, not to this
488
+ * signature.
489
+ *
490
+ * @warning The claim domain must stay below the Jubjub subgroup order `l`:
491
+ * verification compares `g^claimedValue`, so two claims congruent mod `l` are
492
+ * indistinguishable. `Uint<248>` clears `l` (~2^251.86) by under 4 bits, and
493
+ * that width is set by Compact's cap rather than by this bound. 251 is the
494
+ * widest sound `Uint` if the cap ever rises.
495
+ *
455
496
  * Requirements:
456
497
  *
457
498
  * - `ek` is the secret for `pk`.
@@ -466,7 +507,7 @@ module ElGamal {
466
507
  ct: Ciphertext,
467
508
  pk: JubjubPoint,
468
509
  ek: Bytes<32>,
469
- claimedValue: Uint<128>
510
+ claimedValue: Uint<248>
470
511
  ): [] {
471
512
  assertDecryptsToPoint(ct, pk, ek, ecMulGenerator(claimedValue as Field));
472
513
  }
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (multisig/ForwarderPrivate.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (multisig/ForwarderPrivate.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (multisig/ForwarderShielded.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (multisig/ForwarderShielded.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (multisig/ForwarderUnshielded.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (multisig/ForwarderUnshielded.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (multisig/ProposalManager.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (multisig/ProposalManager.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (multisig/ShieldedTreasury.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (multisig/ShieldedTreasury.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (multisig/ShieldedTreasuryStateless.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (multisig/ShieldedTreasuryStateless.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (multisig/Signer.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (multisig/Signer.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (multisig/UnshieldedTreasury.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (multisig/UnshieldedTreasury.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (multisig/presets/ShieldedMultiSig.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (multisig/presets/ShieldedMultiSig.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (multisig/presets/ShieldedMultiSigV2.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (multisig/presets/ShieldedMultiSigV2.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (multisig/presets/forwarder/ForwarderPrivate.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (multisig/presets/forwarder/ForwarderPrivate.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (multisig/presets/forwarder/ForwarderShielded.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (multisig/presets/forwarder/ForwarderShielded.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (multisig/presets/forwarder/ForwarderUnshielded.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (multisig/presets/forwarder/ForwarderUnshielded.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openzeppelin/compact-contracts",
3
- "version": "0.3.0-alpha.2",
3
+ "version": "0.3.0-rc.1",
4
4
  "description": "OpenZeppelin Compact contract library",
5
5
  "keywords": [
6
6
  "openzeppelin",
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (security/Allowlist.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (security/Allowlist.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (security/Blocklist.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (security/Blocklist.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (security/Initializable.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (security/Initializable.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5
 
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-alpha.2 (security/Pausable.compact)
2
+ // OpenZeppelin Compact Contracts v0.3.0-rc.1 (security/Pausable.compact)
3
3
 
4
4
  pragma language_version >= 0.23.0;
5
5