Lux Docs
Fhe

FHE Smart Contracts

Solidity library for encrypted computation

The FHE contracts library provides encrypted types for Solidity smart contracts.

Installation

forge install luxfi/fhe-contracts

Usage

import "fhe-contracts/TFHE.sol";

contract PrivateVoting {
    mapping(uint256 => euint32) private voteCounts;

    function vote(uint256 proposalId, bytes calldata encryptedVote) external {
        euint32 v = TFHE.asEuint32(encryptedVote);
        voteCounts[proposalId] = TFHE.add(voteCounts[proposalId], v);
    }

    function getResult(uint256 proposalId) external view returns (uint32) {
        return TFHE.decrypt(voteCounts[proposalId]);
    }
}

On this page