diff --git a/contracts/DAO/Comp.sol b/contracts/DAO/Comp.sol index 06633e5..f221ec1 100644 --- a/contracts/DAO/Comp.sol +++ b/contracts/DAO/Comp.sol @@ -106,7 +106,7 @@ contract Comp is EncryptedERC20, Ownable2Step { require(from != address(0), "Comp::_transferTokens: cannot transfer from the zero address"); require(to != address(0), "Comp::_transferTokens: cannot transfer to the zero address"); // Add to the balance of `to` and subract from the balance of `from`. - euint64 amountTransferred = TFHE.cmux(isTransferable, amount, TFHE.asEuint64(0)); + euint64 amountTransferred = TFHE.select(isTransferable, amount, TFHE.asEuint64(0)); balances[to] = balances[to] + amountTransferred; balances[from] = balances[from] - amountTransferred; uint256 transferId = saveError(errorCode); diff --git a/contracts/DAO/GovernorZama.sol b/contracts/DAO/GovernorZama.sol index 7485420..acfb61a 100644 --- a/contracts/DAO/GovernorZama.sol +++ b/contracts/DAO/GovernorZama.sol @@ -395,8 +395,8 @@ contract GovernorZama is Reencrypt { require(receipt.hasVoted == false, "GovernorAlpha::_castVote: voter already voted"); euint64 votes = comp.getPriorVotes(voter, proposal.startBlock); - proposal.forVotes = TFHE.cmux(support, proposal.forVotes + votes, proposal.forVotes); - proposal.againstVotes = TFHE.cmux(support, proposal.againstVotes, proposal.againstVotes + votes); + proposal.forVotes = TFHE.select(support, proposal.forVotes + votes, proposal.forVotes); + proposal.againstVotes = TFHE.select(support, proposal.againstVotes, proposal.againstVotes + votes); receipt.hasVoted = true; receipt.support = support; diff --git a/contracts/token/ERC20/EncryptedERC20.sol b/contracts/token/ERC20/EncryptedERC20.sol index 96c3bfa..6ce1b13 100644 --- a/contracts/token/ERC20/EncryptedERC20.sol +++ b/contracts/token/ERC20/EncryptedERC20.sol @@ -153,7 +153,7 @@ abstract contract EncryptedERC20 is Reencrypt, EncryptedErrors { // makes sure the owner has enough tokens ebool canTransfer = TFHE.le(amount, balances[owner]); ebool isTransferable = TFHE.and(canTransfer, allowedTransfer); - _approve(owner, spender, TFHE.cmux(isTransferable, currentAllowance - amount, currentAllowance)); + _approve(owner, spender, TFHE.select(isTransferable, currentAllowance - amount, currentAllowance)); ebool isNotTransferableButIsApproved = TFHE.and(TFHE.not(canTransfer), allowedTransfer); errorCode = changeErrorIf( isNotTransferableButIsApproved, // should indeed check that spender is approved to not leak information @@ -173,7 +173,7 @@ abstract contract EncryptedERC20 is Reencrypt, EncryptedErrors { euint8 errorCode ) internal virtual { // Add to the balance of `to` and subract from the balance of `from`. - euint64 amountTransferred = TFHE.cmux(isTransferable, amount, TFHE.asEuint64(0)); + euint64 amountTransferred = TFHE.select(isTransferable, amount, TFHE.asEuint64(0)); balances[to] = balances[to] + amountTransferred; balances[from] = balances[from] - amountTransferred; uint256 transferId = saveError(errorCode); diff --git a/contracts/utils/EncryptedErrors.sol b/contracts/utils/EncryptedErrors.sol index b076c01..4f9ae2c 100644 --- a/contracts/utils/EncryptedErrors.sol +++ b/contracts/utils/EncryptedErrors.sol @@ -80,7 +80,7 @@ abstract contract EncryptedErrors { function defineErrorIf(ebool condition, uint8 indexCode) internal view returns (euint8) { require(indexCode != 0, "indexCode must be greater than 0"); require(indexCode <= totalNumErrors, "indexCode must be a valid error code"); - euint8 errorCode = TFHE.cmux(condition, errorCodes[indexCode], errorCodes[0]); + euint8 errorCode = TFHE.select(condition, errorCodes[indexCode], errorCodes[0]); return errorCode; } @@ -95,7 +95,7 @@ abstract contract EncryptedErrors { function defineErrorIfNot(ebool condition, uint8 indexCode) internal view returns (euint8) { require(indexCode != 0, "indexCode must be greater than 0"); require(indexCode <= totalNumErrors, "indexCode must be a valid error code"); - euint8 errorCode = TFHE.cmux(condition, errorCodes[0], errorCodes[indexCode]); + euint8 errorCode = TFHE.select(condition, errorCodes[0], errorCodes[indexCode]); return errorCode; } @@ -109,7 +109,7 @@ abstract contract EncryptedErrors { */ function changeErrorIf(ebool condition, uint8 indexCode, euint8 errorCode) internal view returns (euint8) { require(indexCode <= totalNumErrors, "indexCode must be a valid error code"); - return TFHE.cmux(condition, errorCodes[indexCode], errorCode); + return TFHE.select(condition, errorCodes[indexCode], errorCode); } /** @@ -122,7 +122,7 @@ abstract contract EncryptedErrors { */ function changeErrorIfNot(ebool condition, uint8 indexCode, euint8 errorCode) internal view returns (euint8) { require(indexCode <= totalNumErrors, "indexCode must be a valid error code"); - return TFHE.cmux(condition, errorCode, errorCodes[indexCode]); + return TFHE.select(condition, errorCode, errorCodes[indexCode]); } /** diff --git a/package.json b/package.json index 797fa48..9f9a150 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "eslint": "^8.57.0", "eslint-config-prettier": "^8.10.0", "ethers": "^6.11.1", - "fhevm": "0.4.0-3", + "fhevm": "0.4.0-5", "fhevmjs": "0.4.0-7", "fs-extra": "^10.1.0", "hardhat": "^2.21.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c6fe1d1..fe2bf94 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -71,8 +71,8 @@ devDependencies: specifier: ^6.11.1 version: 6.11.1 fhevm: - specifier: 0.4.0-3 - version: 0.4.0-3(hardhat@2.21.0) + specifier: 0.4.0-5 + version: 0.4.0-5(hardhat@2.21.0) fhevmjs: specifier: 0.4.0-7 version: 0.4.0-7 @@ -2861,8 +2861,8 @@ packages: reusify: 1.0.4 dev: true - /fhevm@0.4.0-3(hardhat@2.21.0): - resolution: {integrity: sha512-9tRk4proC/VdGPXUArZbTRzAzBmdazY1CJt1/GRn5TUvv7ZjuelzcXhV5n7QSkJ4MacISCdrmJn240WmTGmWqg==} + /fhevm@0.4.0-5(hardhat@2.21.0): + resolution: {integrity: sha512-P2qmcj1a+9XGXFhoIxqRSNlU9ZOmkSnNe7bHAdJbXSbLnz17I3Jl4y87KSb2eYvJ6WgesDlDpJTKtmHcaqN9uA==} dependencies: '@openzeppelin/contracts': 5.0.2 hardhat-preprocessor: 0.1.5(hardhat@2.21.0)