When the Ethereum network was first proposed in 2014, the original developers did not take ZKP (Zero-Knowledge Proof) technology into account. However, in recent years, ZKP has gained significant attention and is expected to play a more prominent role in the blockchain space. Consequently, there has been an intensified effort to combine ZKP technology with Ethereum’s virtual machine.
To understand what a zkEVM (Zero-Knowledge Ethereum Virtual Machine) is, let’s briefly review its two underlying concepts: zk-rollups and EVM (Ethereum Virtual Machine).
What are zk-rollups?
A rollup is a scaling solution that aggregates multiple transaction executions outside the main chain and sends the data back to the main network as a single transaction. This process increases throughput while reducing the cost of executing these transactions.
On Ethereum, transactions within a rollup are compressed and submitted to the Ethereum mainnet, with the cost of verifying a single transaction. The Ethereum mainnet provides settlement and verifies the transaction data contained in the rollup.
A zk-rollup is a type of rollup that utilizes ZKP technology. ZKP is a cryptographic technique that allows the verification of information’s validity without revealing the information itself. Unlike other rollup solutions, zk-rollups only need to publish state differences (such as changes in user account status) and validity proofs, significantly lowering gas fees.
The security of zk-rollups relies on ZKP cryptography, where cryptographic methods are employed to verify proofs and achieve trustlessness. This differs from other rollup solutions like optimistic rollups, which rely on economic game theory for security, where bad actors are discouraged by potential losses and challengers are motivated by incentives.
What is EVM?
The EVM is a state machine where Ethereum’s account system and smart contracts run. Every execution of a smart contract triggers the EVM to transition from an old state to a new state. The EVM defines rules for calculating new and valid states from one block to another.
State is a critical concept in Ethereum. It refers to a Merkle Patricia Trie data structure that represents Ethereum’s current state and enables anyone to trace transaction information from the current block back to the genesis block.
All nodes participating in maintaining Ethereum ensure continuity and consensus, enabling each node to observe the exact current state. The EVM plays a critical role in maintaining this consistency.
How does zkEVM work?
By default, the EVM does not support ZKPs. However, zkEVM aims to ensure Ethereum’s state continuity while providing proof of the correctness of all information. This ensures that the various factors involved in the computation of these processes are verified while maintaining security and privacy.
zkEVM accomplishes this by replicating the Ethereum environment as zk-rollups. It takes the initial state, performs all the transactions, and outputs a newly updated state along with an accompanying ZKP. This proof is submitted to a verifier smart contract that verifies the correctness of both the initial and new states’ output without having to individually verify all the transactions.
Due to zkEVM’s basis on the EVM, developers can easily port Ethereum DApps and smart contracts to zkEVMs without the need for ZKP development work. In other words, zkEVMs allow zk-rollups to execute smart contracts, expanding beyond token swaps and payments supported without zkEVMs.
The compatibility feature of the EVM enables developers to build new products using existing EVM tools and programming languages such as Solidity, while benefiting from the enhanced security provided by zkEVM. Users can also continue using the same DApps and familiar tools while enjoying added security and privacy.
EVM Compatibility versus EVM Equivalence
When we refer to a blockchain as EVM-compatible, it means that it provides an environment where DApps written in the Solidity programming language can be deployed. Solidity is specifically designed for developing smart contracts that run on the Ethereum network.
Ethereum developers can easily copy and paste the code of existing DApps from Ethereum and deploy them on other EVM-compatible chains with minimal modifications. For users, any EVM-compatible chain address functions the same as their Ethereum address.
This compatibility ensures that addresses can be used with mainstream wallets such as MetaMask and Trust Wallet. Currently, major EVM-compatible chains include BNB Chain, Avalanche C-Chain, and Polygon.
However, it’s important not to confuse EVM compatibility with EVM equivalence. EVM equivalence means that, from the perspective of DApp developers, Layer 2 rollups are nearly identical to Layer 1 Ethereum.
To use an analogy with operating systems, EVM equivalence is like restoring files and settings through Apple Cloud if a user’s previous computer and new computer both run on Apple’s operating system.
In contrast, EVM compatibility means that if a new computer switches to a Windows system, the original files need to be downloaded through cloud storage and converted to recover preferred settings and old files.
Different Types of ZkEVMs
Generating and verifying ZKPs directly using the EVM is extremely slow because Ethereum was not originally designed to support ZKP technology. In some cases, it could take several hours. However, striking a balance between EVM compatibility and ZKP efficiency is important.
Ethereum founder Vitalik Buterin categorized zkEVMs into four types, each with different trade-offs between ZKP performance efficiency and EVM compatibility.
Type 1: Consensus-level equivalence — zkEVM that is completely equivalent to Ethereum
At the consensus level, a Type 1 zkEVM, also known as an enshrined rollup, is equivalent to Ethereum. The zkEVM chain state and transactions are identical to those of Ethereum. They can mutually verify blocks and be directly used with Ethereum execution clients.
Type 1 zkEVMs make Ethereum itself more scalable and can be introduced directly onto the Ethereum mainnet. The drawback is that ZKP efficiency is extremely poor and requires a significant amount of computation for verification. Future solutions could involve using large-scale parallel validators or specialized integrated circuits for zk-SNARKs.
Type 2: Bytecode-level equivalence — completely equivalent to EVM
Type 2 zkEVMs are fully equivalent to the EVM but not Ethereum. They differ from Ethereum in terms of data structures (such as block structure and state tree) and eliminate some stack operations that are not ZK-friendly.
Type 2 zkEVMs are fully compatible with Ethereum’s existing DApps, debugging tools, and developer infrastructure. While they can improve prover times to some extent, they are expensive and have low and expensive efficiency in terms of ZKP.
Type 2.5: Similar to Type 2 but with modifications to gas fees
Type 2.5 zkEVMs share the advantages and disadvantages of Type 2 but have slightly lower gas fees.
Type 3: Bytecode-level equivalence — nearly equivalent to EVM
Building upon Type 2, Type 3 zkEVMs sacrifice compatibility for improved ZK efficiency. They eliminate functions that are difficult to implement on zkEVM, such as precompiles, which may require rewriting some code used in DApps that rely on these functions.
Type 4: Development language-level equivalence — high-level language equivalent to EVM
Type 4 zkEVMs offer the highest ZK performance but relatively subpar compatibility compared to other types. They provide an equivalent high-level language to the EVM.
The primary goal of implementing zkEVM is to enable the integration of ZKP computation into smart contract execution, thereby extending the reach of DApps to all EVM-compatible protocols. However, the applications of ZKP technology extend beyond this point.
ZKP technology has the potential to be compatible with Web2 use cases as well. By combining ZKP with various Web2 applications, Web3 applications can become more seamless and user-friendly. This integration would allow users who are already familiar with traditional Internet browsers to access Web3 and, as a result, accelerate the adoption of Web3 technology.