Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Unofficial Scroll ZK EVM Code Review

Cheng JIANG
September 15, 2023

Unofficial Scroll ZK EVM Code Review

Cheng JIANG

September 15, 2023
Tweet

More Decks by Cheng JIANG

Other Decks in Research

Transcript

  1. Unofficial Scroll ZK EVM
    Code Review
    https://linktr.ee/alexcj96

    View Slide

  2. Summary
    - Why ZK EVM works?
    - Architecture
    - Tech stack comparaison
    - Arithmetization
    - Trace generation
    - Gate configuration
    - Circuit tools
    - Some opcode gadgets
    - Public input circuit
    - Synthesize
    - Combining with halo2
    - Observation

    View Slide

  3. Why ZK EVM works?
    ❖ EVM is a State Machine
    ❖ Public-key cryptography
    ➢ Verify txs all represent users' intention
    ❖ Blockchain consensus
    ➢ Verifier
    ➢ Previous state root
    ❖ MPT
    ➢ Verify initial state
    ➢ Verify new root
    ❖ ZK
    ➢ Succinctness
    ➢ Lookup Arguments
    ❖ Ethereum as a DA Layer

    View Slide

  4. Architecture

    View Slide

  5. Tech stack comparaison

    View Slide

  6. Arithmetization

    View Slide

  7. Trace generation - flow (scroll has simplified this)

    View Slide

  8. Trace generation - types (simplified)

    View Slide

  9. Gate configuration - flow

    View Slide

  10. Gate configuration - gadgets
    Add cb constraints etc

    View Slide

  11. Gate configuration - lookup

    View Slide

  12. Circuit tools - cell manager

    View Slide

  13. Circuit tools - constraint builder

    View Slide

  14. Circuit tools - constraint builder

    View Slide

  15. Circuit tools - utils

    View Slide

  16. Some opcode gadgets - AddSub

    View Slide

  17. Some opcode gadgets - ReturnRevert (simplified)

    View Slide

  18. Public input circuit

    View Slide

  19. Public input circuit

    View Slide

  20. Synthesize

    View Slide

  21. Combining with halo2

    View Slide

  22. Combining with halo2

    View Slide

  23. Observation
    - Scroll doesn’t support self destruct EVM opcode
    - Scroll’s MPT tree uses poseidon circuit
    - Scroll uses chain_id and block_number to calculate block_hash!!!
    - Scroll still uses SuperCircuit which is very zk-unfriendly
    - Don’t read PSE’s code, it’s not production ready!!!
    - …

    View Slide

  24. Thanks!

    View Slide