Skip to content

Commit eab126e

Browse files
james-toussaintarr00
authored andcommitted
Check values are encrypted with FHE.isInitialized(..) (#81)
* Check values are encrypted with FHE.isInitialized(..) * Remove changeset * Calll FHE library with full name * Set empty changeset * Remove empty changeset
1 parent f72fed5 commit eab126e

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

contracts/governance/utils/VotesConfidential.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ abstract contract VotesConfidential is Nonces, EIP712, IERC6372 {
164164
*/
165165
function _moveDelegateVotes(address from, address to, euint64 amount) internal virtual {
166166
CheckpointsConfidential.TraceEuint64 storage store;
167-
if (from != to && euint64.unwrap(amount) != 0) {
167+
if (from != to && FHE.isInitialized(amount)) {
168168
if (from != address(0)) {
169169
store = _delegateCheckpoints[from];
170170
euint64 newValue = store.latest().sub(amount);

contracts/token/ConfidentialFungibleToken.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ abstract contract ConfidentialFungibleToken is IConfidentialFungibleToken {
231231
FHE.checkSignatures(requestId, signatures);
232232

233233
euint64 requestHandle = _requestHandles[requestId];
234-
require(euint64.unwrap(requestHandle) != 0, ConfidentialFungibleTokenInvalidGatewayRequest(requestId));
234+
require(FHE.isInitialized(requestHandle), ConfidentialFungibleTokenInvalidGatewayRequest(requestId));
235235
emit EncryptedAmountDisclosed(requestHandle, amount);
236236

237237
_requestHandles[requestId] = euint64.wrap(0);
@@ -288,7 +288,7 @@ abstract contract ConfidentialFungibleToken is IConfidentialFungibleToken {
288288
_totalSupply = ptr;
289289
} else {
290290
euint64 fromBalance = _balances[from];
291-
require(euint64.unwrap(fromBalance) != 0, ConfidentialFungibleTokenZeroBalance(from));
291+
require(FHE.isInitialized(fromBalance), ConfidentialFungibleTokenZeroBalance(from));
292292
(success, ptr) = TFHESafeMath.tryDecrease(fromBalance, amount);
293293
FHE.allowThis(ptr);
294294
FHE.allow(ptr, from);

contracts/utils/TFHESafeMath.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ library TFHESafeMath {
1515
* and `updated` will be the original value.
1616
*/
1717
function tryIncrease(euint64 oldValue, euint64 delta) internal returns (ebool success, euint64 updated) {
18-
if (euint64.unwrap(oldValue) == 0) {
18+
if (!FHE.isInitialized(oldValue)) {
1919
success = FHE.asEbool(true);
2020
updated = delta;
2121
} else {

0 commit comments

Comments
 (0)