This document describes the architecture of the Shadow-EVM ZK Coprocessor.
Shadow-EVM is a Zero-Knowledge Coprocessor that enables verifiable off-chain Ethereum execution. By embedding revm (Rust EVM) inside a RISC-V ZK-VM (RISC Zero), we can prove the correct execution of Solidity bytecode without running it on-chain.
┌─────────────────────────────────────────────────────────────────┐
│ On-Chain │
│ ┌─────────────┐ ┌──────────────────┐ ┌────────────────┐ │
│ │ dApp │───▶│ ShadowEVMVerifier│───▶│ State Update │ │
│ │ Contract │ │ (Solidity) │ │ Accepted │ │
│ └─────────────┘ └──────────────────┘ └────────────────┘ │
│ │ ▲ │
└─────────│────────────────────│───────────────────────────────────┘
│ │
│ ZK Proof + Commitment
│ │
┌─────────│────────────────────│───────────────────────────────────┐
│ ▼ │ Off-Chain │
│ ┌─────────────┐ ┌──────────────────┐ │
│ │ Host │───▶│ RISC Zero │ │
│ │ (Prover) │ │ Prover │ │
│ └─────────────┘ └──────────────────┘ │
│ │ ▲ │
│ │ │ │
│ ▼ │ │
│ ┌─────────────────────────────────────────────────────────────┐│
│ │ RISC-V ZK-VM (Guest) ││
│ │ ┌───────────────┐ ┌───────────────┐ ┌──────────────┐ ││
│ │ │ExecutionInput │───▶│ ShadowExecutor│───▶│ExecutionOutput│││
│ │ │ (Pre-State) │ │ (revm) │ │ (Post-State) │ ││
│ │ └───────────────┘ └───────────────┘ └──────────────┘ ││
│ └─────────────────────────────────────────────────────────────┘│
└─────────────────────────────────────────────────────────────────┘
The core library provides EVM execution logic that can run in both standard and no_std environments.
Key Types:
| Type | Description |
|---|---|
ExecutionInput |
Block env, transaction, and pre-state |
ExecutionOutput |
Return data, logs, gas used, post-state |
ExecutionCommitment |
Cryptographic binding of input to output |
ShadowExecutor |
Main executor wrapping revm |
InMemoryDB |
ZK-friendly state database |
Execution Flow:
graph LR
A[ExecutionInput] --> B[ShadowExecutor]
B --> C[revm]
C --> D[ExecutionOutput]
D --> E[ExecutionCommitment]
The guest program runs inside the RISC-V ZK-VM. It:
- Reads
ExecutionInputfrom the host - Executes the EVM transaction using
ShadowExecutor - Commits
ExecutionCommitmentto the journal
The guest is compiled to RISC-V ELF and executed inside RISC Zero's prover.
Files:
| File | Purpose |
|---|---|
main.rs |
Entry point, orchestrates execution |
evm/executor.rs |
Wraps ShadowExecutor for ZK use |
evm/host_io.rs |
RISC Zero I/O primitives |
evm/state.rs |
ZK-compatible state wrapper |
The host runs on the developer's machine and:
- Prepares
ExecutionInput - Invokes the RISC Zero prover
- Generates cryptographic receipts (proofs)
- Exports proofs for on-chain verification
CLI Commands:
| Command | Description |
|---|---|
prove |
Generate ZK proof for an execution |
verify |
Verify a ZK proof locally |
export |
Export proof for on-chain submission |
execute |
Run execution without proving (fast) |
sample |
Generate a sample input file |
Smart contract for on-chain proof verification:
- Verifies RISC Zero Groth16 proofs
- Stores verified commitments
- Records state transitions
- Enables state chain verification
sequenceDiagram
participant User
participant Host
participant Prover
participant Guest
User->>Host: ExecutionInput (JSON)
Host->>Prover: Input + Guest ELF
Prover->>Guest: Execute in ZK-VM
Guest->>Guest: Run EVM via revm
Guest->>Prover: Commitment (Journal)
Prover->>Host: Receipt (Proof)
Host->>User: Proof file
sequenceDiagram
participant User
participant Contract
participant RiscZeroVerifier
User->>Contract: verify(seal, journal)
Contract->>RiscZeroVerifier: verify(seal, imageId, digest)
RiscZeroVerifier-->>Contract: true/false
Contract->>Contract: Decode commitment
Contract->>Contract: Store state transition
Contract-->>User: ExecutionCommitment
- Computational Integrity: The ZK proof guarantees the EVM execution was performed correctly
- State Binding: Commitments cryptographically bind pre-state to post-state
- Determinism: Same inputs always produce same outputs (required for ZK)
- On-Chain Verification: Groth16 proofs can be verified in ~200k gas
| Metric | Value |
|---|---|
| Guest Execution | ~1-100M cycles depending on complexity |
| Proof Generation | ~1-60 minutes (depends on cycles) |
| On-Chain Verification | ~200k gas |
| Proof Size (Groth16) | ~256 bytes |
- Parallelization: Split large computations across multiple proofs
- Recursive Proofs: Aggregate multiple proofs into one
- Alternative ZK-VMs: Support SP1, zkWASM
- State Compression: Merkle proofs for partial state