Imagine if everything you did online was completely translucent and publicly available. Your bank account balance, health records, text messages–all readable to anyone with an internet connection.
Sounds crazy, but that’s how Ethereum currently works.
CoFHE is a privacy tool for Ethereum that lets you add encrypted data handling to your smart contracts with just one Solidity import. It operates off-chain for scalable performance and works seamlessly on any EVM-compatible network.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
contract SimpleCounter {
address owner;
uint256 counter;
modifier onlyOwner() {
require(msg.sender == owner, "Only the owner can increment or decrement the counter");
_;
}
constructor(uint initial_value) {
owner = msg.sender;
counter = initial_value;
}
modifier onlyOwner() {
require(msg.sender == owner, "Only the owner can increment or decrement the counter");
_;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
import {FHE, euint64, InEuint64} from "@fhenixprotocol/cofhe-contracts/FHE.sol";
contract SimpleCounter {
address owner;
euint64 counter;
euint64 lastDecryptedCounter;
euint64 step;
modifier onlyOwner() {
require(msg.sender == owner, "Only the owner can access that function");
_;
}
constructor(uint64 initial_value) {
owner = msg.sender;
counter = FHE.asEuint64(initial_value);
FHE.allowThis(counter);
// Encrypt the value 1 only once instead of every value change
step = FHE.asEuint64(1);
FHE.allowThis(step);
}
function increment_counter() external onlyOwner {
counter = FHE.add(counter, step);
FHE.allowThis(counter);
}
function decrement_counter() external onlyOwner {
counter = FHE.sub(counter, step);
FHE.allowThis(counter);
}
function decrypt_counter() external onlyOwner {
lastDecryptedCounter = counter;
FHE.decrypt(lastDecryptedCounter);
}
function get_counter_value() external view returns(uint256) {
(uint256 value, bool decrypted) = FHE.getDecryptResultSafe(lastDecryptedCounter);
if (!decrypted)
revert("Value is not ready");
return value;
}
}
Keep transaction details completely private while preserving verifiable correctness on-chain
FHE locks game logic so no player can reverse-engineer or manipulate data, ensuring a level playing field.
Train Al models on sensitive datasets without revealing a single byte of raw data, or risking detrimental data leaks