Zero-Knowledge Rollups: What Are They and How Do They Work?

Marcel Deer
By Marcel Deer
Head and shoulders photo of Michelle Meyer
Edited by Michelle Meyer

Published November 1, 2022.

A smartphone displaying the Polygon logo against a white screen, with the Polygon website open on a computer screen visible in the back.

Zero-knowledge rollups (ZK-rollups) are a type of scaling solution for blockchains. They allow for cheaper and faster transactions by batching them off-chain into "rollups", while still maintaining the security and privacy of on-chain transactions.

In comparison, in a traditional blockchain transaction, all data and computations are done on-chain, leading to higher fees and slower transaction times.

What Are Zero-Knowledge Rollups?

Following the above definition, an important component of ZK-rollups is a Merkle tree, because it allows ZK-rollups to successfully validate transactions faster.

A Merkle tree is a data structure that can compress large sets of data into a smaller, more efficient representation. This means that Merkle trees only hold the most crucial data needed by the smart contract, saving a lot of processing power and cutting down transaction time drastically.

Other data is stored off-chain and then verified on-chain using zero-knowledge proofs. This allows ZK-rollups to perform better than Layer-1 blockchains and because the blockchain isn't too bogged down in validating transactions, gas fees also decrease.

How Do Zero-Knowledge Rollups Work?

ZK-rollups work by batching multiple transactions off-chain and then creating a cryptographic proof called a zero-knowledge proof (ZKP), that's verified on the blockchain.

Essentially, ZKPs are a way to prove that transactions are valid without revealing the details of those transactions.

The ZK-rollup's core architecture consists of the following two components:

1. On-Chain Contracts

The ZK-rollup protocol is primarily managed by smart contracts running on the Ethereum network. This includes the main contract, which stores data about rollup blocks, tracks deposits made, and monitors state changes or updates. Another on-chain contract called the verifier contract checks ZKPs submitted by block producers. As such, Ethereum is considered the base layer or "Layer-1" for ZK-rollups.

2. Off-Chain Virtual Machine (VM)

The ZK-rollup protocol uses a virtual machine for transaction execution and state storage that's separate from the Ethereum Virtual Machine (EVM). The off-chain VM serves as the ZK-rollup transactions' execution environment. As such, it serves as the secondary layer or "Layer-2" for ZK-rollups.

» How are ZK-rollups implemented? Explore how Polygon uses ZK technologies

Zero-Knowledge Rollups and the Ethereum Blockchain

ZK-rollups utilize the main Ethereum protocol for:

1. Transaction Data Availability

ZK-rollups allow for state data to be published off-chain for every transaction processed. Having transaction data stored on-chain remains crucial for allowing independent and permissionless verification of the Layer-2 chain.

This deters malicious actors from freezing the chain or censoring it. Also, users need on-chain data to interact with the rollup. Without access to state data, users can't check their account balance or carry out transactions that rely on state information.

2. Finality

ZK-rollups use Ethereum as a settlement layer. As such, Layer-2 transactions are only finalized if the Layer-1 contract accepts the validity proof—eliminating the risk of chain corruption by malicious operators. Since every transaction must be approved on Ethereum's mainnet, the network ensures the correctness and finality of Layer-2 transactions. In addition, user operations finalized on Layer-1 are irreversible.

3. Censorship Resistance

ZK-rollups' efficiency also opens them up to the risk of censorship. To remain secure, ZKPs allow users to submit transactions to the mainnet's rollup contract directly, should they suspect that they're being censored by an operator. In such a scenario, users can force exit a ZKP without needing to go through the operator.

» Want to learn more about Ethereum? Read this brief timeline of Ethereum

Zero-Knowledge Rollups Vs. Optimistic Rollups

ZK-rollups and optimistic rollups serve similar functions by allowing off-chain scaling solutions. However, optimistic rollups largely rely on the validity of transaction batches, while ZK-rollups require cryptographic validation.

Optimistic rollups also have a set period in which they can be challenged and disputed. Fraud proofs can be submitted against the transactions during this time frame. As such, optimistic rollups can only work securely as long as honest nodes are submitting fraud proofs when required.

In contrast, ZK-rollups use zero-knowledge proofs to ensure security and validity. Additionally, the amount of data published on-chain is significantly lower for ZK-rollups compared to optimistic rollups, allowing for greater privacy and scalability potential.

» How are optimistic rollups implemented? Discover how Optimism and the Boba Network use optimistic rollups

Conclusion

ZK-rollups offer a secure and efficient solution for scaling on Ethereum. By utilizing the main Ethereum protocol for data availability, finality, and censorship resistance, ZK-rollups can operate as a trusted Layer-2 solution.