Zero-Knowledge vs Optimistic Rollups

MetronomeDAO
6 min readMay 3, 2023

Exploring the fundamental differences between these promising blockchain scaling solutions and their unique trade-offs

Overview

What are the Differences Between ZK and Optimistic Rollups?

In our recent exploration of Layer 2 Protocols, we delved into the world of Optimistic rollups and their potential impact on blockchain scalability. This piece will expand our horizons by comparing Optimistic rollups with another promising Layer 2 solution: ZK-rollups.

The fundamental differences between ZK-rollups and Optimistic rollups lie in their approach to transaction validation and proof generation. To truly grasp these contrasts, let’s examine how each of these technologies operate and highlight the key distinctions between them.

Security

For ZK-rollups, security is rooted in the cryptographic strength of zero-knowledge proofs. These proofs enable the base layer to trust the rollup’s validity without having to process each transaction individually. As a result, the security guarantees of the underlying blockchain remain intact, providing users with a high level of confidence.

Optimistic rollups, however, while still offering security, do it a bit differently. They lean on the fraud-proof mechanism and assumption that validators will catch and challenge any fraudulent transactions. This approach relies on the community’s vigilance to actively monitor and challenge rollups. While it’s still secure, it’s not quite as foolproof as ZK-rollups, since it depends on the active participation of the community.

Validation

With ZK-rollups, the magic lies in zero-knowledge proofs, aka ZK-SNARKs or ZK-STARKs. These proofs confirm the accuracy of a batch of transactions without revealing their details. They’re created off-chain and backed by strong cryptography, which guarantees the bundled transaction’s validity. The base layer of the blockchain only needs to verify the proof, saving on computational power and storage space.

On the other hand, Optimistic rollups take a different approach by relying on fraud-proofs. Instead of using cryptographic proofs, they assume transactions within a rollup are valid by default. Now, you might wonder what happens if there’s a fraudulent transaction lurking inside. Well, that’s where the challenge period comes in. If someone spots a bad transaction, they can submit a fraud-proof during this period. If the fraud-proof checks out, the rollup gets reverted, and the wrongdoer faces penalties. You may also be thinking, can’t someone spam the network with false fraud proofs? The answer is yes, however, they are encouraged not to through economic incentives.

Smart-Contract Compatibility

As stated above, since ZK-rollups use ZK-SNARKs and ZK-STARKs, it can be a bit of a double-edged sword. While these zero-knowledge proofs provide security and privacy, they can also limit support for complex smart contracts. The reason behind this is that generating and verifying proofs for intricate smart contracts can be quite computationally demanding.

On the flip side, Optimistic rollups have a leg up in this area. They operate within the same execution environment as the base layer, like the Ethereum Virtual Machine (EVM) for Ethereum-based applications. This compatibility means they can fully support complex smart contracts, making them a versatile choice for a broader array of decentralized applications.

Confirmation Times

In the case of ZK-rollups, transactions achieve finality the moment the base layer verifies the zero-knowledge proof. This instant finality translates into a more seamless user experience, as confirmation times are significantly faster.

However, Optimistic rollups operate differently due to their reliance on fraud-proof mechanisms. There’s a challenge period in place, during which rollups can be contested if any fraudulent transactions are detected. This waiting game can take hours, making confirmation times longer compared to those of ZK-rollups. Users need to be patient and wait for the challenge period to pass before they can consider their transactions final and irreversible.

How Do Both Solutions Work?

So now we know the fundamental differences between the two, let’s get into more detail about how these solutions actually work and find out what terms such as “ZK-SNARKs and ZK-STARKs” actually mean.

At the heart of ZK-rollups is the zero-knowledge proof, a cryptographic technique that enables one party to prove the validity of a statement without revealing any specific information about it. In the context of ZK-rollups, the proof is created using ZK-SNARKs (Zero-Knowledge Succinct Non-Interactive Argument of Knowledge) or ZK-STARKs (Zero-Knowledge Scalable Transparent Argument of Knowledge). The beauty of this approach is that it offloads most of the computational work off-chain, while the base layer merely needs to verify the proof. This results in higher throughput, reduced gas fees, and enhanced privacy.

Let’s break down the ZK-rollup process:

  1. An aggregator collects multiple transactions from users off-chain.
  2. The aggregator bundles these transactions into a “rollup” and creates a new Merkle tree that represents the updated state.
  3. Using either ZK-SNARKs or ZK-STARKs, the aggregator generates a zero-knowledge proof that confirms the rollup’s validity.
  4. The aggregator then submits the proof and the Merkle root of the updated state to the base layer (Layer 1) of the blockchain.
  5. Layer 1 verifies the proof, updates the on-chain state with the new Merkle root, and emits an event to notify users.
Visual Representation of how ZK-rollups Work — Source: MetaSchool

Optimistic rollups take a more optimistic approach to transaction validation, hence the name. Instead of using cryptographic proofs, they assume that transactions within a rollup are valid by default. The system relies on the community to keep an eye on rollups and detect any fraudulent activity. Let’s take a closer look at the process:

  1. An aggregator collects multiple transactions from users off-chain, just like in ZK-rollups.
  2. The aggregator executes the transactions in the rollup and generates a new Merkle tree representing the updated state.
  3. The aggregator submits the Merkle root of the updated state to the base layer (Layer 1) of the blockchain without a cryptographic proof.
  4. The base layer stores the Merkle root and starts a challenge period, typically lasting several hours.
  5. During the challenge period, users or validators can submit fraud proofs if they detect any invalid transactions in the rollup.
  6. If no fraud proofs are submitted within the challenge period, the rollup is considered valid, and the on-chain state is updated accordingly.

Optimistic rollups trade cryptographic assurance for a more trust-based system that relies on the vigilance of its users. While this approach has its benefits, like full support for smart contracts, it also introduces longer confirmation times due to the challenge period.

Source: Dealroom

Summary

In a nutshell, ZK-rollups rely on cryptographic zero-knowledge proofs, such as ZK-SNARKs and ZK-STARKs, to validate transaction bundles. They offer enhanced security, privacy, and instant finality. However, their support for complex smart contracts is limited, and the development process can be more complex.

On the other hand, Optimistic rollups use a fraud-proof mechanism that assumes transactions are valid by default. They offer full smart contract support and easier development. However, they come with lower security guarantees and longer confirmation times due to the challenge period associated with fraud-proofs.

--

--

MetronomeDAO

A community-drive DeFi ecosystem. Our first protocol, Synth, is now live in beta - https://app.metronome.io