What is zkEVM? Importance of zkEVM for Ethereum Scaling 2022
What is zkEVM? Importance of zkEVM for Ethereum Scaling
The computer of the World. The machine is unstoppable. The Heart of Ethereum. The Ethereum Virtual Machine (EVM) goes by many names that highlight its importance to the Ethereum network. It is the core feature that makes it not only a ‘distributed ledger’ like Bitcoin but also a ‘distributed state machine’. EVM allows developers to create smart contracts using a programming language called Solidity. A common application of smart contracts is to manage token generation and exchange. Many applications and protocols use tokens to reward users for actions that are important to their goal. Without EVM, this would not be possible so the EVM virtual machine, a technology that made Ethereum famous, helps to execute smart contracts on the Ethereum network. What about zkEVM? is it as important as the EVM virtual machine?
What is zkEVM?
zkEVM (zero-knowledge Ethereum Virtual Machine) is a virtual machine that supports zero-knowledge proofs or ZKP to verify the correctness of the execution of programs, including the validity of inputs and outputs in the program.
Simply put, zkEVM is designed to execute smart contracts that support zero-knowledge (zk) technology.
The importance of zkEVM
First, let’s review the importance of zk technology. ZKP (zero-knowledge proofs) is a way to prove a state is true without having to reveal any more information so that users keep privacy such as personal information, business secrets, proprietary data… Especially in the Web3 space, privacy is indispensable. For example, thanks to zk you can use the web without having your personal information stolen, or use proprietary data as input to activate smart contracts.
zkEVM leverages the resources of Ethereum, leveraging the scalability, validity, low cost, capital efficiency of zk-Rollup technology and the privacy capabilities of zk technology:
- With Layer 2, zk-Rollup could not initially execute smart contracts, only able to execute simple swaps or payments. However, with the advent of zkEVM, zk-Rollup is supporting smart contracts and making it easy for developers to develop dApps with the familiar Solidity language.
- With Layer 1 using zk technology like Mina, zkEVM makes proof of state directly provable on Ethereum, thereby opening a bridge between Mina and zk and Ethereum technology.
Is zkEVM a determining factor in the development of zk technology? the answer is no. For example, some non-EVM projects like StarkNet use Warp to compile Solidity language to Cairo or Polygon Miden uses the MidenVM virtual machine.
So why zkEVM and not another virtual machine? As mentioned above, it is zkEVM that helps to leverage resources from Ethereum such as:
- Familiar tools for developers like Truffle, Hardhat, and Foundry
- Established security best practices
- Deploy existing modular smart contracts via OpenZeppelin
- Many audit firms have expertise in EVM
- The largest Web3 developer community
- Users are familiar with EVM-based blockchain utilities such as Etherscan, metamask wallet, etc.
zkEVM powers the Ethereum scaling solution. As we know zk-Rollup is said to be Ethereum’s medium and long-term scaling solution with many advantages such as scalability up to 2000TPS (4x Optimistic-Rollup), proof-of-validation, cost low fees, efficient capital (it only takes ~10 minutes to withdraw money to L1 while Optimistic is 1 week). zkEVM elevates the zk-Rollup scaling solution through EVM compatibility, making it easy for developers to leverage resources from Ethereum.
How zkEVM works
To understand how zkEVM works, let’s first review how EVM works today.
How the EVM virtual machine works
Virtual machines work in a similar way to physical machine with storage, memory, and CPU, but they operate entirely as code.
- The contract bytecode (compiled from the source code) is loaded from the EVM’s storage and executed by the peer nodes on the EVM. The nodes use the same inputs, which ensures that each node arrives at the same result (or else they cannot reach a consensus).
- EVM Opcodes (included in bytecode) perform read-write operations i.e. read values from state storage and write new values to EVM’s memory.
- EVM opcodes perform computations of values obtained from state storage before returning new values. This update results in the EVM transitioning to the new state (transactions are called “state transitions” for this reason). This new state is copied by other nodes and maintained until another transaction is committed.
How zkEVM works
Like the EVM, zkEVM is a virtual machine that transitions between states after program execution. But zkEVM goes even further by generating zero-knowledge proofs (ZKPs) that verify the different factors in each calculation:
- Bytecode Access: Is the appropriate program code loaded properly, from the correct address?
2. Read and write operations:
- Does the program fetch the matching values from the stack/memory/storage (stack/memory/storage) before calculating?
- Does the program write the correct output values to the stack/memory/storage (stack/memory/storage) after completing the execution?
3. Calculation: Are the opcodes executed correctly?
ZkEVM is divided into three parts: an execution environment, a proving circuit, and a verifier contract. Each component contributes to zkEVM’s program execution, proof generation, and proof verification.
The execution environment is where programs (smart contracts) are run in zkEVM. zkEVM’s execution environment works like an EVM: it takes the initial state and the current transaction to create a new (aka final) state.
The proof circuit generates zero-knowledge proofs (ZKPs) that verify the validity of computed transactions in the execution environment.
Proof generation is completed using input data consisting of (1) pre-state, (2) transaction input, and (3) post-state information.
The verifier then obtains a brief proof of the validity of that particular state transition.
ZK-rollups submit valid proof to a smart contract deployed on the L1 (Ethereum) chain for verification.
Input (previous state and transaction information) and output (final state) are also submitted to the verifier contract.
The verifier then runs computations on the provided proof and confirms that the submitted outputs were correctly calculated from the inputs.
What are zkEVM opcodes?
zkEVM opcodes are low-level machine instructions used to execute programs in an EVM-compatible zk-Rollup.
We need zkEVM opcodes because conventional EVM opcodes are not efficient for use in zero-knowledge proof circuits. In general, there are two approaches to generating zkEVM opcodes:
Building ZK Circuits for Original EVM opcodes
This approach makes zkEVM compatible at the bytecode level equivalent to EVM. This means that developers can create smart contracts using an existing blockchain developer tool, or migrate existing Ethereum contracts to ZK-rollups without much modification. However, it is a rather complicated and time-consuming technical endeavor.
Create a new language for ZK proof computation
This approach required building a new language — designed to support validators — and developing custom opcodes. Developers will need to either write contracts directly in the new language or compile the Solidity source code into custom zkEVM opcodes.
Although this method is often simpler to implement than the first approach, it has limitations. For example, developers may not be able to access existing Ethereum infrastructure and resources.
zkEVM is one of the most important factors that help developers build/integrate their dApps on the zk technology platform using the familiar solidity language.
Especially with zk-Rollup, zkEVM helps developers take full advantage of Ethereum’s resources, taking advantage of the scalability, validity, low cost, and capital efficiency of zk-Rollup technology and the carrying capacity Back to the privacy of zk technology. If the effort to build zkEVM is successful, the Ethereum ecosystem will certainly continue to retain a competitive edge over other alternative L1s.
The zkEVM space is likely to heat up in the coming months as zkSync makes its way to mainnet, Scroll, Polygon zkEVM runs testnet.
DISCLAIMER: The Information on this website is provided as general market commentary and does not constitute investment advice. We encourage you to do your own research before investing.
Join CoinCu Telegram to keep track of news: https://t.me/coincunews