Files
fhevm-solidity/examples/CMUX.sol
Joseph-André Turk 535b055fc8 Updated Solidity version to ^0.8.20 and OpenZeppelin Contracts to ^5.0.1
updated to ethermint node

updated node dev version

removed parallel flag from hardhat test

reput inband test for ci

setup evm version to Paris to avoid PUSH0 error and updated hardhat version

removed utils.ts.new file

synced package.json and package-lock.json

prettier
2024-01-09 11:05:38 +01:00

29 lines
877 B
Solidity

// SPDX-License-Identifier: BSD-3-Clause-Clear
pragma solidity ^0.8.20;
import "../abstracts/Reencrypt.sol";
import "../lib/TFHE.sol";
// Shows the CMUX operation in Solidity.
contract CMUX is Reencrypt {
euint8 internal result;
constructor() {}
// Set result = if control { ifTrue } else { ifFalse }
function cmux(bytes calldata controlBytes, bytes calldata ifTrueBytes, bytes calldata ifFalseBytes) public {
ebool control = TFHE.asEbool(controlBytes);
euint8 ifTrue = TFHE.asEuint8(ifTrueBytes);
euint8 ifFalse = TFHE.asEuint8(ifFalseBytes);
result = TFHE.cmux(control, ifTrue, ifFalse);
}
function getResult(
bytes32 publicKey,
bytes calldata signature
) public view onlySignedPublicKey(publicKey, signature) returns (bytes memory) {
return TFHE.reencrypt(result, publicKey);
}
}