FHE State OS: Bringing Public Infrastructure Onchain While Protecting Citizens' Privacy

February 12, 2025
Jason Delabays

The concept of “network state” has been gaining traction among technologists and policy enthusiasts worldwide. Proponents such as Balaji Srinivasan envision entirely digital-first communities, while others like Vitalik Buterin explore physical enclaves—often in special economic zones—to foster innovation in areas like longevity research. Despite their differences, these visions share a core belief: blockchain technology can streamline governance and collective decision-making by reducing intermediaries, increasing transparency when necessary and keeping information private when needed. 

A Framework for Digital Communities

However, transparency in blockchain systems can be a double-edged sword. Many early crypto adopters face challenges in areas like currency, taxation, and public spending, mainly because traditional blockchains expose too much data. This hinders the adoption of blockchain-based infrastructures for critical government functions, where confidentiality is essential for personal records, tax filings, and state-level decision-making. Enter the idea of Zama's FHE State OS (Operating System): a blockchain-based, robust, and efficient IT infrastructure designed for entire states or communities that safeguard privacy by default using Fully Homomorphic Encryption. By integrating identity and monetary functions, it seeks to manage everything from tax collection to public spending with minimal reliance on third parties. Blockchains are especially suited for this because they remove the need for a centralized intermediary, thus lowering costs and potential points of failure.

Privacy by Default with Fully Homomorphic Encryption

Yet, achieving privacy on public ledgers requires advanced cryptographic tools. Zero-Knowledge (ZK) proofs offer one route, enabling users to prove something without revealing the underlying data. Another promising approach is Fully Homomorphic Encryption (FHE), which allows computations on encrypted data without the need to decrypt. FHE-based solutions are starting to show real promise in tackling the tension between transparency and confidentiality. Some industry players—quietly working on bridging these technologies—believe that once sophisticated privacy solutions become standard for network states, traditional institutions will follow suit.

A practical example of this vision of privacy-focused blockchain governance is the hackathon ran by Crecimiento in December 2024, where developers experimented with confidential smart contracts to build a new framework for Argentinian citizen services and decentralized budgeting. The results demonstrated that integrating encryption at the protocol level—such as in FHE-capable environments—can preserve blockchain’s core benefits (integrity, immutability) while meeting the privacy requirements typically demanded by national and local governments.

Looking ahead, innovators see potential in applying FHE to serve as the backbone for a privacy-preserving State OS. This could streamline critical operations without exposing sensitive data. Although these solutions are still evolving, they represent a step toward safer, more trustworthy digital governance.

Contributing to Innovation

For those interested in shaping the future of government services and digital nations, now is the time to explore privacy-enhancing technologies on smart contract platforms. By participating in open hackathons, experimenting with prototype systems, or contributing to ecosystems that support homomorphic encryption, developers and entrepreneurs can pioneer the next wave of public infrastructure.

Ultimately, as network states gain influence, solutions that balance blockchain’s transparency with strong privacy will redefine how we manage public resources, conduct political processes, and ensure data confidentiality. The race to build the next generation of state infrastructure is already underway.

Are You a Developer? Write Your First Confidential Smart Contract Today

Using Zama's fhEVM, developers can write confidential smart contracts just as they would write regular ones, in plain solidity. If you're interested in getting started, you can check out our step-by-step demos on the Zama's fhEVM documentation.

Confidential ERC-20 Transfer.

A variation of the standard ERC20 smart contract that incorporates encrypted balances, providing additional privacy for token holders.


contract EncryptedERC20{
    // ...
    function transfer(address to, einput encryptedAmount, bytes calldata inputProof) public {
        ebool canTransfer = TFHE.le(amount, _balances[msg.sender]); // Ensure owner has enough tokens
        euint64 transferValue = TFHE.select(isTransferable, amount, TFHE.asEuint64(0));
        euint64 newBalanceTo = TFHE.add(_balances[to], transferValue); // Add to the balance of `to`
        _balances[to] = newBalanceTo;
        TFHE.allowThis(newBalanceTo);
        TFHE.allow(newBalanceTo, to);
        euint64 newBalanceFrom = TFHE.sub(_balances[from], transferValue); // Subtract to the balance of `for`
        _balances[from] = newBalanceFrom;
        TFHE.allowThis(newBalanceFrom);
        TFHE.allow(newBalanceFrom, from);
    }
}
// Read full code at https://github.com/zama-ai/fhevm-contracts/blob/main/contracts/token/ERC20/ConfidentialERC20.sol

Confidential Voting System.

DAO smart contract that facilitates governance decisions through encrypted voting.


contract VotingDapp is GatewayCaller, Ownable {
    uint256 public dateEndVote;
    uint256 public totalVotes;
    euint64 internal totalVotesForProposalEncrypted;
    uint64 public totalVotesForProposalResult;
    bool public finalResultIsDecrypted;

    mapping(address user => bool canVote) public isWhiteListed;
    mapping(address user => bool hasVoted) public hasAlreadyVoted;
    /// ...

    constructor(uint256 voteDuration) Ownable(msg.sender) {
        dateEndVote = block.timestamp + voteDuration;
        totalVotesForProposalEncrypted = TFHE.asEuint64(0);
        TFHE.allowThis(totalVotesForProposalEncrypted);
    }

    function whiteListUser(address user) external onlyOwner {
        isWhiteListed[user] = true;
    }

    function castVote(einput encryptedSupport, bytes calldata inputProof) external {
        if (block.timestamp >= dateEndVote) revert TooLateToCastVote();
        if (!isWhiteListed[msg.sender] || hasAlreadyVoted[msg.sender]) revert UserUnauthorized();
        ebool voteFor = TFHE.asEbool(encryptedSupport, inputProof);
        totalVotesForProposalEncrypted = TFHE.add(totalVotesForProposalEncrypted, TFHE.asEuint64(voteFor));
        TFHE.allowThis(totalVotesForProposalEncrypted);
        totalVotes++;
        hasAlreadyVoted[msg.sender] = true;
    }

    function requestRevealVoteResult() external { // anyone could request to decrypt the final result after end of the voting period
        if (block.timestamp < dateEndVote) revert TooEarlyToRevealResult();

        // Request decryption of vote results through the Gateway
        uint256[] memory cts = new uint256[](1);
        cts[0] = Gateway.toUint256(totalVotesForProposalEncrypted);
        Gateway.requestDecryption(cts, this.revealVoteResult.selector, 0, block.timestamp + 100, false);
    }

    function revealVoteResult(uint256 /*requestId*/, uint64 result) external onlyGateway {
        totalVotesForProposalResult = result;
        finalResultIsDecrypted = true;
    }

    function isProposalVoted() public view returns (bool) {
        if (!finalResultIsDecrypted) revert ResultNotRevealedYet();
        if (2 * totalVotesForProposalResult >= totalVotes) return true;
        return false;
    }
}
// Read full code at https://github.com/zama-ai/fhevm-contracts/blob/main/contracts/governance/ConfidentialERC20Votes.sol

Confidential Decentralized Identity System.

A blockchain-based identity management system using smart contracts to store and manage encrypted personal data.


contract DID is Ownable {
    struct Identity {
        euint128 id; // Encrypted unique ID
        ebytes64 name; // Encrypted name
        euint64 birthdate; // Encrypted birthdate for age verification
    }
    mapping(address user => Identity) private citizenIdentities;
    // ...

    /// @dev Owner is able to add new identity for a specific user addres
    function registerIdentity(
        address user, einput name_, einput birthdate_, bytes calldata inputProof
    ) public onlyOwner {
        euint64 newId = TFHE.randEuint128(); // Generate a new encrypted random unique ID
        citizenIdentities[user] = Identity({
            id: newId,
            name: TFHE.asEbytes64(name_, inputProof),
            birthdate: TFHE.asEuint64(birthdate_, inputProof)
        });
        /// @dev Allow the user to access their own data
        TFHE.allow(citizenIdentities[user].id, addressToBeAllowed);
        TFHE.allow(citizenIdentities[user].name, addressToBeAllowed);
        TFHE.allow(citizenIdentities[user].birthdate, addressToBeAllowed);

        /// @dev Allow the contract to access the data
        TFHE.allowThis(citizenIdentities[user].id);
        TFHE.allowThis(citizenIdentities[user].name);
        TFHE.allowThis(citizenIdentities[user].birthdate);
    }

    /// @dev Grants claim contract access to encrypted birth date
    function generateAgeClaim(address claimAddress, string memory claimFn) public {
        TFHE.allowTransient(citizenIdentities[msg.sender].birthdate, claimAddress);
        (bool success, bytes memory data) = claimAddress.call(abi.encodeWithSignature(claimFn, msg.sender));
        if (!success) revert ClaimGenerationFailed(data);
    }

    function getBirthdate(address user) public view returns (euint64) {
        return citizenIdentities[user].birthdate;
    }
}

contract EmployerClaim {
  mapping(address user => ebool isAdult) private adultClaims;
  // ...

  /// @dev Generates an encrypted claim verifying if a user is above 18 years old
  function generateAdultClaim(address user) public {
      if (msg.sender != address(didContract)) revert NotAuthorized();
      euint64 birthdate = didContract.getBirthdate(user); // Retrieve user's encrypted birthdate from the DID contract
      ebool isAdult = TFHE.le(birthdate, _AGE_THRESHOLD); // Check if user is adult
      adultClaims[user] = isAdult; // Store claim result
      TFHE.allowThis(isAdult);
      TFHE.allow(isAdult, user);
  }
}
// Read full code at https://github.com/poppyseedDev/FHEPass/blob/main/contracts/PassportID.sol

Additional Links

Read more related posts