@openzeppelin/confidential-contracts 0.2.0 → 0.3.0
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/build/contracts/Checkpoints.json +2 -2
- package/build/contracts/CheckpointsConfidential.json +2 -2
- package/build/contracts/{ConfidentialFungibleToken.json → ERC7984.json} +87 -58
- package/build/contracts/{ConfidentialFungibleTokenERC20Wrapper.json → ERC7984ERC20Wrapper.json} +143 -59
- package/build/contracts/ERC7984Freezable.json +700 -0
- package/build/contracts/ERC7984ObserverAccess.json +710 -0
- package/build/contracts/ERC7984Omnibus.json +1028 -0
- package/build/contracts/ERC7984Restricted.json +711 -0
- package/build/contracts/ERC7984Rwa.json +1385 -0
- package/build/contracts/{ConfidentialFungibleTokenUtils.json → ERC7984Utils.json} +4 -4
- package/build/contracts/{ConfidentialFungibleTokenVotes.json → ERC7984Votes.json} +142 -113
- package/build/contracts/FHESafeMath.json +2 -2
- package/build/contracts/{IConfidentialFungibleToken.json → IERC7984.json} +26 -7
- package/build/contracts/{IConfidentialFungibleTokenReceiver.json → IERC7984Receiver.json} +2 -2
- package/build/contracts/IERC7984Rwa.json +797 -0
- package/build/contracts/VestingWalletConfidentialFactory.json +2 -2
- package/finance/ERC7821WithExecutor.sol +3 -4
- package/finance/VestingWalletCliffConfidential.sol +3 -4
- package/finance/VestingWalletConfidential.sol +8 -12
- package/finance/VestingWalletConfidentialFactory.sol +7 -12
- package/interfaces/{IConfidentialFungibleToken.sol → IERC7984.sol} +6 -5
- package/interfaces/{IConfidentialFungibleTokenReceiver.sol → IERC7984Receiver.sol} +3 -3
- package/interfaces/IERC7984Rwa.sol +63 -0
- package/package.json +4 -4
- package/token/{ConfidentialFungibleToken.sol → ERC7984/ERC7984.sol} +81 -82
- package/token/{extensions/ConfidentialFungibleTokenERC20Wrapper.sol → ERC7984/extensions/ERC7984ERC20Wrapper.sol} +40 -35
- package/token/ERC7984/extensions/ERC7984Freezable.sol +75 -0
- package/token/ERC7984/extensions/ERC7984ObserverAccess.sol +63 -0
- package/token/ERC7984/extensions/ERC7984Omnibus.sol +209 -0
- package/token/ERC7984/extensions/ERC7984Restricted.sol +110 -0
- package/token/ERC7984/extensions/ERC7984Rwa.sol +248 -0
- package/token/{extensions/ConfidentialFungibleTokenVotes.sol → ERC7984/extensions/ERC7984Votes.sol} +8 -14
- package/token/{utils/ConfidentialFungibleTokenUtils.sol → ERC7984/utils/ERC7984Utils.sol} +14 -13
- package/utils/FHESafeMath.sol +45 -7
- package/utils/structs/temporary-Checkpoints.sol +2 -2
package/utils/FHESafeMath.sol
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Confidential Contracts (last updated v0.
|
|
2
|
+
// OpenZeppelin Confidential Contracts (last updated v0.3.0) (utils/FHESafeMath.sol)
|
|
3
3
|
pragma solidity ^0.8.24;
|
|
4
4
|
|
|
5
5
|
import {FHE, ebool, euint64} from "@fhevm/solidity/lib/FHE.sol";
|
|
@@ -7,6 +7,9 @@ import {FHE, ebool, euint64} from "@fhevm/solidity/lib/FHE.sol";
|
|
|
7
7
|
/**
|
|
8
8
|
* @dev Library providing safe arithmetic operations for encrypted values
|
|
9
9
|
* to handle potential overflows in FHE operations.
|
|
10
|
+
*
|
|
11
|
+
* NOTE: An uninitialized `euint64` value (equivalent to euint64.wrap(bytes32(0))) is evaluated as 0.
|
|
12
|
+
* This library will may return an uninitialized value if all inputs are uninitialized.
|
|
10
13
|
*/
|
|
11
14
|
library FHESafeMath {
|
|
12
15
|
/**
|
|
@@ -16,13 +19,11 @@ library FHESafeMath {
|
|
|
16
19
|
*/
|
|
17
20
|
function tryIncrease(euint64 oldValue, euint64 delta) internal returns (ebool success, euint64 updated) {
|
|
18
21
|
if (!FHE.isInitialized(oldValue)) {
|
|
19
|
-
|
|
20
|
-
updated = delta;
|
|
21
|
-
} else {
|
|
22
|
-
euint64 newValue = FHE.add(oldValue, delta);
|
|
23
|
-
success = FHE.ge(newValue, oldValue);
|
|
24
|
-
updated = FHE.select(success, newValue, oldValue);
|
|
22
|
+
return (FHE.asEbool(true), delta);
|
|
25
23
|
}
|
|
24
|
+
euint64 newValue = FHE.add(oldValue, delta);
|
|
25
|
+
success = FHE.ge(newValue, oldValue);
|
|
26
|
+
updated = FHE.select(success, newValue, oldValue);
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
/**
|
|
@@ -31,7 +32,44 @@ library FHESafeMath {
|
|
|
31
32
|
* and `updated` will be the original value.
|
|
32
33
|
*/
|
|
33
34
|
function tryDecrease(euint64 oldValue, euint64 delta) internal returns (ebool success, euint64 updated) {
|
|
35
|
+
if (!FHE.isInitialized(oldValue)) {
|
|
36
|
+
if (!FHE.isInitialized(delta)) {
|
|
37
|
+
return (FHE.asEbool(true), oldValue);
|
|
38
|
+
}
|
|
39
|
+
return (FHE.eq(delta, 0), FHE.asEuint64(0));
|
|
40
|
+
}
|
|
34
41
|
success = FHE.ge(oldValue, delta);
|
|
35
42
|
updated = FHE.select(success, FHE.sub(oldValue, delta), oldValue);
|
|
36
43
|
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @dev Try to add `a` and `b`. If the operation is successful, `success` will be true and `res`
|
|
47
|
+
* will be the sum of `a` and `b`. Otherwise, `success` will be false, and `res` will be 0.
|
|
48
|
+
*/
|
|
49
|
+
function tryAdd(euint64 a, euint64 b) internal returns (ebool success, euint64 res) {
|
|
50
|
+
if (!FHE.isInitialized(a)) {
|
|
51
|
+
return (FHE.asEbool(true), b);
|
|
52
|
+
}
|
|
53
|
+
if (!FHE.isInitialized(b)) {
|
|
54
|
+
return (FHE.asEbool(true), a);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
euint64 sum = FHE.add(a, b);
|
|
58
|
+
success = FHE.ge(sum, a);
|
|
59
|
+
res = FHE.select(success, sum, FHE.asEuint64(0));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @dev Try to subtract `b` from `a`. If the operation is successful, `success` will be true and `res`
|
|
64
|
+
* will be `a - b`. Otherwise, `success` will be false, and `res` will be 0.
|
|
65
|
+
*/
|
|
66
|
+
function trySub(euint64 a, euint64 b) internal returns (ebool success, euint64 res) {
|
|
67
|
+
if (!FHE.isInitialized(b)) {
|
|
68
|
+
return (FHE.asEbool(true), a);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
euint64 difference = FHE.sub(a, b);
|
|
72
|
+
success = FHE.le(difference, a);
|
|
73
|
+
res = FHE.select(success, difference, FHE.asEuint64(0));
|
|
74
|
+
}
|
|
37
75
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Confidential Contracts (last updated v0.
|
|
3
|
-
// OpenZeppelin Contracts (last updated v5.
|
|
2
|
+
// OpenZeppelin Confidential Contracts (last updated v0.3.0) (utils/structs/temporary-Checkpoints.sol)
|
|
3
|
+
// OpenZeppelin Contracts (last updated v5.4.0) (utils/structs/Checkpoints.sol)
|
|
4
4
|
// This file was procedurally generated from scripts/generate/templates/Checkpoints.js.
|
|
5
5
|
// WARNING: This file is temporary and will be deleted once the latest version of the file is released in v5.5.0 of @openzeppelin/contracts.
|
|
6
6
|
|