@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.
- 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/ElGamal.compact +44 -3
- 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/presets/ShieldedMultiSig.compact +1 -1
- package/multisig/presets/ShieldedMultiSigV2.compact +1 -1
- package/multisig/presets/forwarder/ForwarderPrivate.compact +1 -1
- package/multisig/presets/forwarder/ForwarderShielded.compact +1 -1
- package/multisig/presets/forwarder/ForwarderUnshielded.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 +253 -67
- 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 +63 -19
- 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/Utils.compact +11 -1
package/access/Ownable.compact
CHANGED
package/crypto/EcdhMask.compact
CHANGED
package/crypto/ElGamal.compact
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Compact Contracts v0.3.0-
|
|
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(
|
|
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<
|
|
510
|
+
claimedValue: Uint<248>
|
|
470
511
|
): [] {
|
|
471
512
|
assertDecryptsToPoint(ct, pk, ek, ecMulGenerator(claimedValue as Field));
|
|
472
513
|
}
|
package/multisig/Signer.compact
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Compact Contracts v0.3.0-
|
|
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-
|
|
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-
|
|
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