Enabling compatibility with zero-knowledge proof (ZKP) technology, the zero-knowledge Ethereum Virtual Machine (zkEVM) functions as an Ethereum state machine, facilitating the execution of smart contracts. The integration of zkEVMs expands the scope of zero-knowledge rollups (zk-rollups) on the Ethereum network to include decentralized applications (DApps). This advancement simplifies the deployment of Ethereum projects, whether they are pre-existing or novel, by harnessing ZKPs to amplify the capabilities of the Ethereum ecosystem.
When the Ethereum network was initially proposed in 2014, the concept of zero-knowledge proof technology was not taken into account by the original developers. Nevertheless, in recent years, ZKP has garnered significant attention and is anticipated to assume a more substantial role in the blockchain domain. Consequently, there has been a surge in efforts to integrate ZKP technology with Ethereum's virtual machine.
To grasp the essence of a zkEVM, it is necessary to provide a concise overview of its two foundational principles: zk-rollups and EVM.
What Are Zk-Rollups?
By compiling multiple transaction executions off the main chain and transmitting the data as a single transaction to the main network, rollups serve as a scaling solution that enhances throughput and reduces transaction costs.
Within the Ethereum ecosystem, rollup transactions undergo compression and are subsequently transmitted to the Ethereum mainnet for verification at the cost of a single transaction. The Ethereum mainnet serves the purpose of settlement and verifies the transaction data encompassed within the rollup.
A specific variant of rollups, known as zk-rollups, leverages zero-knowledge proof technology. ZKP technology enables the verification of information's validity without disclosing the information itself. In the case of zk-rollups, it is unnecessary to publish all transaction data to the Ethereum mainnet; instead, solely state differences, such as alterations in user account status, along with validity proofs are required. This approach substantially reduces gas fees.
The security of zk-rollups is grounded in ZKP cryptography, which employs cryptographic mechanisms to verify proofs and establish trustlessness. This stands in contrast to other rollup implementations, such as optimistic rollups, which rely on economic game theory for security. In optimistic rollups, bad actors are disincentivized due to potential losses, while challengers are motivated by incentives.
What Is EVM?
Within Ethereum, the Ethereum Virtual Machine (EVM) functions as a state machine that facilitates the operation of the Ethereum account system and the execution of smart contracts. Each execution of a smart contract prompts the EVM to transition from an old state to a new state, following the predefined rules for computing valid states between blocks.
The notion of state holds significant importance in the Ethereum ecosystem. It is represented by a Merkle Patricia Trie data structure, serving as a snapshot of the current state of Ethereum. This structure enables the tracing of transaction details from the present block all the way back to the genesis block.
The collective effort of all participating nodes in maintaining Ethereum ensures continuity and consensus, granting each node visibility into the precise current state. The EVM assumes a pivotal role in upholding this consistency, safeguarding the integrity of the Ethereum network.
How Does a ZkEVM Functionate?
Ensuring Ethereum state continuity and providing verifiable correctness, zkEVM emerges as a solution to the absence of default support for zero-knowledge proofs in the EVM. This approach guarantees the validation of all involved computation factors, maintaining security and privacy simultaneously.
In the realm of zkEVM, the Ethereum environment is replicated akin to zk-rollups. Starting from the initial state, all transactions are processed, resulting in an updated state accompanied by an associated ZKP. This proof is subsequently submitted to a verifier smart contract responsible for validating the accuracy of both the initial and the updated states' outputs, eliminating the need for individual transaction verification.
zkEVMs, built upon the foundation of the EVM, offer developers the convenience of seamlessly porting Ethereum DApps and smart contracts to zkEVMs without undertaking ZKP development tasks. In essence, zkEVMs extend the functionality of zk-rollups to encompass smart contract execution, in addition to the token swaps and payments previously supported without zkEVM integration.
Thanks to the compatibility feature inherited from the EVM, developers can construct novel products utilizing existing EVM tools and the Solidity programming language, while benefiting from the heightened security delivered by zkEVM. Users, too, experience the same advantages as they continue utilizing familiar DApps and tools, now fortified with enhanced security and privacy measures.
Distinguishing EVM Compatibility and EVM Equivalence
When a blockchain is labeled as EVM-compatible, it signifies that it provides an environment capable of hosting DApps written in the Solidity programming language, specifically tailored for Ethereum smart contract development.
In fact, Ethereum developers have the ability to seamlessly transfer existing DApp code from Ethereum to other EVM-compatible chains with minimal adjustments. For users, an EVM-compatible chain's address is indistinguishable from their Ethereum address.
Consequently, these addresses are compatible with popular wallets like Metamask and Trust Wallet. Notable EVM-compatible chains presently include BNB Chain, Avalanche C-Chain, and Polygon.
It's essential not to conflate EVM compatibility with EVM equivalence. EVM equivalence denotes that, from a DApp developer's perspective, Layer 2 rollups closely resemble Layer 1 Ethereum. To illustrate with an operating system analogy, EVM equivalence is comparable to restoring files and settings via Apple Cloud when transitioning from an old computer to a new computer operating on Apple's system.
In contrast, EVM compatibility signifies that if one switches to a Windows system on a new computer, the original files must be retrieved through cloud storage and converted to restore preferred settings and old files.
Categorizing zkEVMs: Balancing Efficiency and Compatibility
Efficient generation and verification of ZKPs using the EVM is a challenge due to Ethereum's lack of inherent support for ZKP technology. The process can be exceedingly slow, with potential durations spanning several hours. Nevertheless, it remains crucial to find a balance between EVM compatibility and ZKP efficiency.
Vitalik Buterin, the founder of Ethereum, has classified zkEVMs into four distinct types, each embodying unique tradeoffs concerning ZKP performance efficiency and EVM compatibility. These classifications parallel the concept of the blockchain trilemma, which highlights the inherent tradeoffs among decentralization, security, and scalability.
Type 1: Consensus-Level Equivalence
Type 1 zkEVM, also known as an enshrined rollup, achieves complete equivalence with Ethereum at the consensus level. The zkEVM chain state and transactions mirror those of Ethereum, enabling mutual block verification and direct integration with Ethereum execution clients. Although this type enhances Ethereum's scalability, ZKP efficiency remains a significant drawback, requiring substantial computational resources for verification. Potential solutions include employing parallel validators on a large scale or specialized integrated circuits for zk-SNARKs.
Type 2: Bytecode-Level Equivalence
Type 2 zkEVMs possess complete equivalence with the EVM, but not with Ethereum itself. While maintaining compatibility with existing Ethereum DApps, debugging tools, and developer infrastructure, Type 2 zkEVMs optimize prover times to some extent. However, their efficiency remains limited and costly, lacking synergy with ZK methodologies.
Type 2.5: Modified Gas Fees
Type 2.5 zkEVMs share the advantages and disadvantages of Type 2, but offer slightly reduced gas fees.
Type 3: Bytecode-Level Equivalence With Improved Efficiency
Building upon Type 2, Type 3 zkEVMs prioritize enhanced ZK efficiency over complete compatibility. To achieve this, certain functions, such as precompiles, are omitted, necessitating the rewriting of DApps that rely on these functionalities.
Type 4: Development Language-Level Equivalence
Type 4 zkEVMs exhibit optimal ZK performance but sacrifice compatibility at the high-level language level. While providing superior efficiency, their compatibility with existing systems may be subpar.
The implementation of zkEVM serves a primary objective of enabling ZKP computation support for smart contract execution, thus extending DApps to encompass all EVM-compatible protocols. However, the applications of ZKP technology extend beyond this domain.
ZKP technology holds the potential for compatibility with Web2 use cases. By combining ZKP with various Web2 applications, the integration of Web3 applications can be seamlessly enhanced, offering users a smoother and more user-friendly experience. This approach enables individuals familiar with traditional Internet browsers to access the benefits of Web3, ultimately driving widespread adoption of the Web3 paradigm.