βœ… Master ZK Circuit Design

Understand circuits, constraints, and proof generation for ZK rollups

Build zero-knowledge circuits for rollups

Key Takeaways

You've learned how ZK-Rollup circuits enable scalable blockchain computation through cryptographic proofs. Let's review the key concepts before testing your knowledge.

πŸ”’ Circuit Fundamentals

ZK circuits are arithmetic circuits operating over finite fields (BN254), composed of addition and multiplication gates. Unlike boolean circuits, they work with field elements and algebraic constraints.

  • β€’Multiplication gates are expensiveβ€”they create constraints
  • β€’Addition gates are cheapβ€”multiple can be combined linearly
  • β€’Circuit size determines proving time (fewer gates = faster proofs)

πŸ“ Constraint Systems

Three major constraint systems power modern ZK-Rollups, each with different tradeoffs:

  • β€’R1CS/Groth16: Smallest proofs (128-192 bytes), trusted setup, 280k gas verification
  • β€’PLONK: Universal setup, custom gates, larger proofs (384-512 bytes), 300k gas
  • β€’STARKs/AIR: Transparent (no trusted setup), post-quantum, large proofs (45-200 KB), 5M gas

⚑ Proof Generation

Four-stage pipeline converts transactions into verifiable proofs:

  • β€’Witness Generation: Execute circuit with private inputs to compute wire values
  • β€’Polynomial Commitment: Commit to witness polynomial cryptographically
  • β€’Proof Construction: Generate proof using FFTs and elliptic curve operations
  • β€’Verification: Constant-time verification on L1 (~300k gas regardless of batch size)

πŸ“Š Performance Optimizations

Modern provers achieve 1000+ TPS through specialized hardware and algorithms:

  • β€’GPU/FPGA acceleration for FFTs and Multi-Scalar Multiplication (70% of proving time)
  • β€’Recursive proofs: aggregate multiple batches into one proof
  • β€’Batching strategy: larger batches = lower cost per tx (300k gas Γ· batch size)

πŸš€ Real-World Impact

Production ZK-Rollups process millions of transactions daily:

  • β€’zkSync Era: Plonk circuits, 2000+ TPS, $2B+ TVL
  • β€’StarkNet: STARK proofs, Cairo language, post-quantum security
  • β€’Polygon zkEVM: EVM equivalence, Plonk/FFlonk, Groth16 final proof
  • β€’Cost reduction: From 21k gas per tx on L1 β†’ 300-600 gas on L2 (35-70x cheaper)