Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/0xchriswilder/journey/llms.txt

Use this file to discover all available pages before exploring further.

Week 1: Foundations of Confidential Computing

Subtitle: Understand FHE, set up tooling, grasp FHEVM architecture Estimated Time: 8 hours of lessons + 3 hours homework

Objectives

Understand FHE

Define Fully Homomorphic Encryption and explain why it matters for blockchain privacy

Dev Environment

Set up complete FHEVM development environment with Hardhat and MetaMask

Network Config

Connect wallet to Sepolia testnet and obtain test ETH

FHEVM Architecture

Master encrypted types, operations, and the FHEVM data flow

Milestone

Working dev environment with wallet connected to Sepolia
Solid understanding of FHE fundamentals
Completed FHE Concepts & Setup Verification homework

Lessons

Lesson 1.1: Welcome to FHEVM

Duration: 30 minutes
  • Define Fully Homomorphic Encryption in your own words
  • Explain how FHEVM brings FHE to Ethereum
  • Identify 3+ real-world use cases for confidential computing
  • Describe the high-level FHEVM data flow: encrypt → compute → decrypt
What is Fully Homomorphic Encryption?FHE allows computation on encrypted data without ever decrypting it. Think of it as performing math on a locked safe — you can add, subtract, and calculate inside without ever seeing the contents.
Traditional encryption requires decryption before processing — exposing sensitive data. FHE eliminates this vulnerability entirely.
The Zama Protocol & FHEVMFHEVM is an EVM-compatible runtime that exposes FHE types and operations in smart contracts via the Zama Solidity library.The core flow:
  1. Client encrypts input
  2. Contract computes on ciphertexts
  3. Contract marks values as publicly decryptable
  4. Client performs off-chain decryption via the Relayer SDK
  5. Client submits the cleartext + proof back on-chain for verification
Real-World Use Cases

Confidential Voting

Votes remain encrypted during voting. Only the final tally is revealed.

Sealed-Bid Auctions

Bidders submit encrypted bids. The contract determines the winner without revealing losing bids.

Private Token Transfers

Transfer amounts stay hidden while the contract validates balances.

Confidential DeFi

Lending protocols where positions and balances remain private.
FHEVM Data Flow

Lesson 1.2: Environment & Wallet Setup

Duration: 45 minutes
  • Install Node.js (v18+), npm, and verify versions
  • Clone and configure the FHEVM Hardhat template
  • Set up environment variables for Sepolia testnet
  • Install and configure MetaMask wallet
  • Connect wallet to Sepolia and obtain test ETH from faucet
Step 1: Install Node.js & npm
# Verify Node.js installation
node --version   # Should show v18.x.x or higher

# Verify npm installation
npm --version    # Should show 9.x.x or higher

# If using nvm (recommended):
nvm install 18
nvm use 18
Step 2: Clone the FHEVM Hardhat Template
# Clone the official FHEVM template
git clone https://github.com/zama-ai/fhevm-hardhat-template.git
cd fhevm-hardhat-template

# Install dependencies
npm install

# Copy the example environment file
cp .env.example .env
Step 3: Configure Environment Variables
.env
# .env file configuration
MNEMONIC="your twelve word mnemonic phrase here"
# OR use a private key:
PRIVATE_KEY="0xYourPrivateKeyHere"
NEVER commit your .env file to git — it contains sensitive keys. Use a dedicated development wallet with testnet funds only.
Step 4: Wallet & Network Setup
  1. Install MetaMask browser extension
  2. Create a new wallet or import existing (use a dedicated dev wallet)
  3. Add Sepolia testnet to MetaMask
  4. Get test ETH from Sepolia faucet
Step 5: Verify Everything Works
# Compile contracts to verify setup
npx hardhat compile

# Run a quick test
npx hardhat test

# If everything passes, your environment is ready!

Lesson 1.3: FHE Deep Dive

Duration: 60 minutes
  • List all FHEVM encrypted types and when to use each one
  • Write homomorphic operations: add, sub, mul, comparison, select
  • Explain the role of FHE.allowThis() and FHE.allow()
  • Describe public vs. private decryption and when to use each
  • Draw the FHEVM architecture diagram from memory
Encrypted true/false. Use for flags, conditions, and binary choices.Range: true or false (encrypted)
Encrypted 8-bit unsigned integer (0-255).Use for: Small values like votes, ratings, simple countersGas: Cheapest encrypted type
Encrypted 16-bit unsigned integer (0-65535).Use for: Medium-range values
Encrypted 32-bit unsigned integer.Use for: Larger counters, timestamps, vote tallies (FHEVM v0.9+ standard)
Encrypted 64-bit unsigned integer.Use for: Token amounts, balances, large financial values
Encrypted large integers.Use for: Cryptographic values, very large balancesGas: Most expensive encrypted types
Encrypted address type.Use for: Private recipient addresses
Gas Optimization Tip: Always use the smallest type that fits your data — smaller types use less gas.
Arithmetic Operations
// Addition
euint32 sum = FHE.add(a, b);

// Subtraction (WRAPS on underflow - see safe patterns)
euint32 diff = FHE.sub(a, b);

// Multiplication
euint32 product = FHE.mul(a, b);
Comparison Operations
// Greater than
ebool isGreater = FHE.gt(a, b);

// Greater than or equal
ebool isGte = FHE.gte(a, b);

// Less than
ebool isLess = FHE.lt(a, b);

// Equality
ebool isEqual = FHE.eq(a, b);
Encrypted Ternary (FHE.select)
// Replaces if/else for encrypted conditions
euint32 result = FHE.select(
    condition,      // ebool
    valueIfTrue,    // euint32
    valueIfFalse    // euint32
);
You cannot use regular if/else with encrypted conditions. Always use FHE.select() instead.
FHE.allowThis() — Grants the contract permission to work with an encrypted valueFHE.allow(value, address) — Grants a specific address permission to decrypt a value privatelyFHE.makePubliclyDecryptable(value) — Marks a ciphertext so anyone can request its decryption off-chainSelf-Relaying Decryption Flow (v0.9+)
// Step 1 (on-chain): Mark value as publicly decryptable
encryptedValue = FHE.makePubliclyDecryptable(encryptedValue);
bytes32 handle = FHE.toBytes32(encryptedValue);
emit ValueReadyForDecryption(handle);

// Step 2 (off-chain, in frontend):
// Client uses @zama-fhe/relayer-sdk to call publicDecrypt(handle)
// This returns { cleartext, decryptionProof }

// Step 3 (on-chain): Verify and use the decrypted result
function resolveCallback(
    bytes memory cleartexts,
    bytes memory decryptionProof
) external {
    bytes32[] memory handlesList = new bytes32[](1);
    handlesList[0] = handle;
    FHE.checkSignatures(handlesList, cleartexts, decryptionProof);
    uint32 result = abi.decode(cleartexts, (uint32));
    // Use the verified decrypted result...
}
In v0.9+, there is no Oracle. The dApp client drives decryption off-chain and submits the proof back on-chain.

Homework: FHE Concepts & Setup Verification

Estimated Time: 3 hours Objective: Demonstrate your understanding of FHE fundamentals and verify your development environment is fully configured.

Requirements

Answer 10 written questions about FHE, FHEVM, and the Zama Protocol. Submit as a markdown file.Sample questions:
  • What does FHE stand for and what makes it “fully” homomorphic?
  • Name three real-world use cases for FHEVM and explain why each needs encrypted computation
  • In the FHEVM data flow, list the 5 steps from user input to on-chain result
Submit screenshots showing:
  • Node.js version (node --version)
  • Successful Hardhat compilation (npx hardhat compile)
  • MetaMask connected to Sepolia testnet
Given 5 scenarios, choose the appropriate FHEVM encrypted type and justify your choice in 1-2 sentences each.Example: “A user’s age (0-150)” → euint8 (max 255, cheapest gas)
Draw (or write in mermaid syntax) the FHEVM architecture diagram from memory, labeling each component and data flow.

Grading Criteria

CriterionWeightDescription
Conceptual Understanding40%Accuracy and depth of answers to conceptual questions
Setup Verification40%Evidence of a working development environment
Bonus Exploration20%Extra credit for exploring beyond the lesson material

Submission

1

Create folder

Create a folder named homework-1-[yourname]
2

Include files

  • answers.md with your written responses
  • screenshots/ folder with verification images
  • architecture.md or architecture.mmd with your diagram
3

Submit

Zip the folder and submit — [Submission portal coming soon]

Next Steps

Continue to Week 2

Now that you understand FHE fundamentals and have your environment set up, move on to Week 2 to write your first FHEVM smart contract.

Build docs developers (and LLMs) love