ZK, short for Zero-Knowledge, refers to a set of protocols and services that utilize the cryptographic technique Zero-Knowledge proof. These proofs allow one party to prove the validity of a fact to another party without revealing the underlying information (1). Picture a person using ZK-proofs to affirm income eligibility for a loan without disclosing their exact earnings. Or imagine an election where votes are confirmed as valid and counted, yet the voters' identities and choices remain undisclosed.
Besides privacy, ZK technology also enhances Layer 2 blockchain development by boosting scalability with ZK Rollups, enabling secure cross-chain transactions for improved interoperability, and optimizing smart contract execution for minimal fees.
What Are ZK-Rollups?
Zero-knowledge rollups (ZK-rollups) are Layer 2 scaling techniques that combine multiple transactions into batches, reducing the amount of data sent to the blockchain. Here's how they work:
- Transaction bundling: ZK-rollups group transactions together into batches, known as rollups. Instead of sending each transaction individually, these rollups contain a summary of the changes needed to represent all the transactions.
- Off-chain execution: The execution of these transactions happens off-chain, meaning it doesn't directly involve the blockchain. This reduces the computational load and data size required to be posted on the blockchain.
Validity proofs: ZK-rollup operators generate validity proofs to prove the correctness of the batched transactions. The validity proof assures, with cryptographic reliability, that the proposed alterations to Ethereum's state accurately reflect the outcome of executing the entire transaction batch (2).
What is EVM?
Ethereum Virtual Machine (EVM) is an intangible entity that operates across thousands of connected computers, ensuring the continuous functioning of Ethereum's system while hosting all accounts and smart contracts (3).
Figure 1. Diagram adapted from Ethereum EVM illustrated
Source: @0xbhagi on Ethereum
Here's what you need to know:
- State transition: Each block on Ethereum contributes to a unique official ‘state’. The EVM manages state through a process called state transitions. Each transaction within a block triggers a state transition, which involves taking the current state of the blockchain, executing a transaction, and resulting in a new state.
- Smart contract execution: If the transaction involves a smart contract, the EVM runs the contract's code, which may update the state, emit events, or even call other contracts. The EVM manages transactions, ensuring they're valid, properly signed, correctly sequenced, and have enough gas fees.
- ‘Merkle Patricia Trie’: Ethereum uses this data structure to store its state and allows for efficient verification and updating of data, as well as enabling some advanced features such as “state pruning” to manage the growth of the blockchain state (4).
Remember, the EVM is Turing-complete, meaning it can execute any algorithm given enough resources.
What Exactly is zkEVM?
The EVM does not support Zero-Knowledge Proofs (ZKP). That's where zkEVM comes in with several functions:
- Ensuring continuity and proof: zkEVM replicates the Ethereum environment using ZK-rollups. It takes the initial state, processes transactions, and generates an updated state along with a proof called a ZKP. This proof is then checked by a verifier smart contract, which ensures the correctness of both states without verifying each transaction.
- Compatibility and ease of development: Since zkEVM is built on the EVM, developers can easily port existing Ethereum dApps and smart contracts to zkEVM without additional ZKP development work. This means that ZK-rollups can execute smart contracts, token swaps, and payments, which was previously impossible.
Enhanced security and familiarity: With EVM compatibility, developers can build new products using familiar tools like Solidity, a popular Ethereum programming language. Users can continue using the same dApps and tools they are familiar with, but with added security and privacy provided by zkEVM (5).
Types of zkEVM
There are different types of zkEVMs, each achieving privacy preservation in different ways.
Figure 2. Types of zkEVM in Compatibility and Performance Correlation
Source: Vitalik Buterin's website
Type 1 (fully Ethereum-equivalent)
This type can verify an environment that is exactly like Ethereum, including Ethereum itself. It has the ability to scale Ethereum Layer 1, not just rollups. It is extremely convenient for rollups because infrastructure can be shared. However, generating proofs with this type takes a significant amount of time.
Type 2 (fully EVM-equivalent)
This type can verify an environment that closely resembles Ethereum, but there are slight differences in their external features, such as the block structure and state tree (the data map between addresses and account states) that don't affect the application layer. It is fully compatible with nearly all Ethereum applications and can share most infrastructure. While there are improvements, generating proofs with this type still requires a considerable amount of time.
A case in point: Scroll's zkEVM project is currently working on developing a Type 2. However, they are still in the process of implementing the more complex pre-compiles. More on zkEVM Layer 2 solutions will be presented at KBW 2023.
Figure 3. Scroll admin @jordan replied to a user on April 17, 2023
Source: Scroll Discord
Type 2.5 (EVM-equivalent, except for gas costs)
This type modifies the EVM by adjusting gas costs. It allows for faster proof generation but introduces a few incompatibilities.
Type 3 (almost EVM-equivalent)
This type can verify an environment that is similar to Ethereum, but with minor changes that do impact the application layer, such as a different hash function or the absence of pre-compiles, a contract performing complex cryptographic computations without EVM overhead. It is fully compatible with most Ethereum applications and can share a significant amount of infrastructure. Proof generation is faster compared to the previous types.
Type 4 (high-level-language equivalent)
This type compiles high-level smart contract code, like Solidity or Vyper, into a language optimized for ZK-SNARKs. This optimization significantly speeds up the proof generation process. However, it is not compatible with some Ethereum applications and cannot utilize much of the existing infrastructure. The faster proof generation time helps save costs and reduces centralized risk (6).
The different types of zkEVM cannot be definitively ranked in terms of overall effectiveness. Lower-numbered types may have slower speeds but offer better compatibility with existing infrastructure. On the other hand, higher-numbered types may be faster but lack compatibility. The exploration of various zkEVM types by different projects contributes to the ongoing evolution of zkEVM and Ethereum.
Challenges and Potential of zkEVM
Initially, EVM was not designed with ZKP computations in mind. This resulted in certain characteristics that are not compatible with proof circuits, including special opcodes, a stack-based architecture, storage overheads, and high proof costs. Therefore, the transition to such a future is expected to take a significant amount of time.
Looking ahead, we can expect multiple implementations of zkEVM that will support not only ZK-rollups but also the verification of the Ethereum chain itself. In theory, Ethereum doesn't necessarily require a single standard zkEVM for its first layer (L1), as different clients could utilize different proofs. In the meantime, the journey towards Ethereum scaling and the adoption of Ethereum-based ZK-rollups will continue to witness innovative advancements.
- Bitstamp Learn, What is ZK technology?, January 19th, 2023
- @d1onys1us on Ethereum, Zero-Knowledge Rollups, May 5, 2023
- @0xbhagi on Ethereum, Ethereum Virtual Machine (EVM), March 18, 2023
- @nozotrox on Ethereum, Merkle Patricia Trie, April 18, 2023
- Binance Academy, What Is a ZkEVM and How Can It Enhance the Ethereum Ecosystem?, Apr 14, 2023
- Vitalik Buterin, The different types of ZK-EVMs, August 04, 2022
- Scroll, Design challenges of zkEVM
Established in 2022, M3TA is an AI-enabled data analytics platform dedicated to Web3 & emerging blockchains. Our team, composed of experts from Stanford, MIT, and Fortune 300 companies and seasoned in Defi, NFT, Metaverse & Gaming and Web3, distills over 10TB of data, covering 500+ projects and 5K+ tokens to produce clear insights for all audience levels. Boasting a robust presence in Korea, Vietnam, and South-East Asia, and spanning an evolving partner network, most currently with Google Cloud and FactBlock, M3TA is your trusted partner in unraveling blockchain complexities.
Writer & Reviewer: Research Analysts & Content Writers at M3TA Analytics
#zk #EVM #zkEVM #Ethereum #M3TA