mirror of
https://github.com/luxfhe/example-redact.git
synced 2026-10-30 18:13:20 +00:00
- @luxfhe/wasm: ^0.2.0 - @luxfhe/kms: ^0.2.0 - @luxfhe/relayer-sdk: ^0.6.0 - @luxfhe/mock-contracts: ^0.6.0 - Remove deprecated Zama dependencies
38 lines
955 B
Solidity
38 lines
955 B
Solidity
//SPDX-License-Identifier: MIT
|
|
pragma solidity >=0.8.0 <0.9.0;
|
|
|
|
// Import FHE.sol library
|
|
import "@luxfi/contracts/fhe/FHE.sol";
|
|
|
|
// Useful for debugging. Remove when deploying to a live network.
|
|
import "hardhat/console.sol";
|
|
|
|
contract FHEContract {
|
|
euint32 public val;
|
|
|
|
constructor() {
|
|
val = FHE.asEuint32(0);
|
|
}
|
|
|
|
function setVal(Euint32 memory _inVal) public {
|
|
val = FHE.asEuint32(_inVal);
|
|
FHE.allowSender(val);
|
|
FHE.allowThis(val);
|
|
}
|
|
|
|
function valOp(uint8 op, Euint32 memory _operand) public {
|
|
euint32 operand = FHE.asEuint32(_operand);
|
|
if (op == 0) {
|
|
val = FHE.add(val, operand);
|
|
} else if (op == 1) {
|
|
val = FHE.sub(val, operand);
|
|
} else if (op == 2) {
|
|
val = FHE.mul(val, operand);
|
|
} else if (op == 3) {
|
|
val = FHE.div(val, operand);
|
|
}
|
|
FHE.allowSender(val);
|
|
FHE.allowThis(val);
|
|
}
|
|
}
|