mirror of
https://github.com/zama-ai/fhevm-solidity.git
synced 2026-04-17 03:00:47 -04:00
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
29 lines
877 B
Solidity
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);
|
|
}
|
|
}
|