Operating System

FHE State OS*

"Privacy is necessary for an open society in the electronic age."
Trusted by some of the top network states, like Praxis and Vitalia.city.

Introducing the FHE
State OS by Zama

Running a fully-fledged community onchain requires strong confidentiality to preserve democracy. This is why Fully Homomorphic Encryption (FHE) has the power to play a crucial role in the development of network states.

Learn more

Get Started

What is a network state?

A network state is a digitally-native community built on shared values, goals, and interests, where members organize, interact, and govern themselves primarily through decentralized technologies.

Unlike traditional states tied to physical geography, network states rely on blockchain and other Web3 technologies to establish a digital "nation state" with decentralized governance, transparent decision-making, and verifiable interactions.

These communities can form virtual economies, create enforceable agreements, and even integrate into real-world operations, blending digital and tangible systems to create new kinds of sovereignty.

Jambo Bento Background Dots
Jambo Bento Background Dots

Why confidentiality is needed for a network state?

Confidentiality is essential for network states because protecting sensitive personal and organizational data fosters trust among community members.

Without confidentiality, private information such as member identities, voting patterns, or financial transactions could be exposed, risking the security and autonomy of the community.

For a network state to function effectively, its members need to trust that their data will remain private while still enabling transparency for governance and accountability.

Confidentiality ensures that decisions are made freely, relationships are safeguarded, and members are empowered to participate fully without fear of surveillance or exploitation.

Jambo Bento Background Dots

Why is FHE the perfect solution for network states?

Fully Homomorphic Encryption (FHE) is a groundbreaking technology that allows data to remain encrypted while being processed, enabling computations on encrypted data without ever exposing the plaintext.

This capability makes FHE an ideal solution for network states allowing them to embed confidentiality directly into the infrastructure. With FHE, network states can ensure that voting, governance, and financial operations remain secure and private, even when running entirely onchain.

By combining the decentralization of blockchain with the privacy guarantees of FHE, network states can build systems that operate without requiring inherent trust, achieving both transparency and confidentiality—crucial for scaling governance, protecting member data, and achieving true digital sovereignty.

Other Important Resources

Examples

The Building Blocks Of A Network State

Discover the essential components of a network state and how Fully Homomorphic Encryption can help ensure privacy and trust at every layer.

Democracy and Governance
Identity and Property Management
Financial and Economic System

Build Your First Confidential dApp With These Step-By-Step Demos

Using Zama's fhEVM, developers can write confidential smart contracts just as they would write regular ones.

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);
    }
}
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;
    }
}
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);
  }
}