12 min read

ZK-Rollups: Explained

Your Easy Guide to Blockchain’s Newest Technology!

Cover Image

Published on

4 Dec, 2023

Imagine a layer one blockchain network as a small popcorn machine in a busy movie theatre. In the beginning, when there are just a few people, this machine can make enough popcorn for everyone. But as the number of moviegoers increases, the machine starts struggling to keep up. People wait longer, and the cost of popcorn might even go up due to high demand. This situation is similar to what we are witnessing with popular blockchain networks like Bitcoin and Ethereum. Initially, they could handle the number of transactions (like orders for popcorn) quite well. But now, with so many people using these networks, they can't process transactions fast enough, leading to delays and higher costs.

Scalability, everyone needs some popcorn

Bitcoin can only handle about 7 transactions per second (TPS), and Ethereum (L1 alone) about 15 TPS. This was fine in the early days of cryptocurrencies, but not anymore with the growing user base. To solve this, the blockchain community is looking for ways to process transactions quicker, a concept known as "scaling." One method is by scaling Layer 1 (L1) of the blockchain, which can be referred as upgrading the main popcorn machine to serve more people at once. This can involve allowing for higher transaction capacity, using bigger blocks that can store more transactions, or improving the software that manages these transactions.

Another solution is to take some activities off the main blockchain, known as "off-chain" solutions, similar to setting up additional popcorn stands around the theatre. This way, not everyone has to wait in line at the main machine. These off-chain solutions are part of what's known as Layer 2 (L2) protocols. They work on top of the existing blockchain (Layer 1) to improve how it handles transactions. Examples of these Layer 2 solutions include State Channels, Sidechains, Plasma Chains, Optimistic Rollups, and zk-Rollups. Each of these employ a different strategy to ensure everyone gets their popcorn quickly and without overloading the main machine.

Layer 2 Solutions

Let's take a look at some of the Layer 2 solutions which are designed to address the scalability concerns. This will help us get some background knowledge to understand rollups in detail.

State Channels:

State channels are like private pathways for two or more parties to conduct transactions off the main blockchain. They operate on mutual consensus between parties, differing from the broader network's consensus, which is ideal for repeated interactions in applications like gaming or micro-transactions. They're efficient and cost-effective, as they don't need every transaction to be announced to the whole network. A prime example is the Lightning Network on Bitcoin, enabling quick, off-chain transactions with reduced fees.

Sidechains:

We can think of sidechains as neighboring chains to the main blockchain. They allow assets to move back and forth between the main and side chains, enhancing interaction and asset exchange between different blockchain networks. However, they need their own security mechanisms. The Liquid Network on Bitcoin and networks like Polygon PoS on Ethereum are examples where sidechains enhance transaction speed and liquidity.

Plasma Chains:

Plasma is a framework that creates a network of child chains linked to a main blockchain, like branches on a tree. These child chains handle most of the transactions, reducing the load on the main chain. They have their own rules and can be tailored for specific needs, but rely on the main chain for overall security and finality.

While these Layer 2 solutions offer significant improvements in scalability and efficiency, they are not without drawbacks. Full Layer 2 schemes like sidechains, plasma, and channels face challenges in ensuring complete data availability and security. For example, in plasma or sidechain models, if a malicious operator withholds crucial data, users may be unable to challenge invalid transactions. These disadvantages underscore the importance of carefully considering the trade-offs of each Layer 2 solution.

Understanding Rollups: The Preferred Layer 2 Solution

After exploring various Layer 2 solutions and understanding their shortcomings, the blockchain community has largely converged on the use of Rollups as a key strategy to address scalability challenges. Rollups are adept at balancing the load by shifting computation and state storage off the main blockchain (Layer 1) while retaining certain data for each transaction on-chain. This approach offers several advantages:

  • On-Chain Data Availability: By keeping transaction data on-chain, Rollups ensure that anyone can process operations within the rollup independently. This capability is crucial for detecting fraud, initiating withdrawals, or producing transaction batches, enhancing the security and reliability of the system.

  • Reduced Risk of Malicious Activities: With data readily available on-chain, the risk posed by malicious or offline operators is significantly mitigated. For instance, such operators can not cause extended delays, as seen in some other Layer 2 solutions. This opens up more possibilities for who can publish batches, simplifying the management of Rollups.

  • General-Purpose Functionality: Perhaps most importantly, the elimination of data availability issues removes the need to map assets to specific owners. This aspect is particularly exciting for the Ethereum community, as it allows Rollups to be fully general-purpose. Developers can run an Ethereum Virtual Machine (EVM) inside a Rollup, enabling existing Ethereum applications to transition to Rollups with minimal changes to the code. This seamless migration promises to revolutionize how applications interact with blockchain technology, making Rollups a versatile and powerful tool in the blockchain toolkit.

Types of Rollups

Optimistic Rollups and Fraud Proofs:

Optimistic Rollups operate under the assumption that all transactions within a rollup are initially valid until proven otherwise. This method speeds up transaction processing by eliminating the need for immediate verification. However, it incorporates a crucial security mechanism known as fraud proofs. In Optimistic Rollups, the contract maintains a history of all state roots and the hash of each transaction batch. If a user identifies an incorrect post-state root in a batch, they can submit a fraud proof to the blockchain. This proof demonstrates that the batch was computed incorrectly. Upon verification of this proof, the contract will revert the erroneous batch and all subsequent batches. This system ensures integrity but introduces a waiting period for fund withdrawals, characteristic of networks like Optimism or Arbitrum.

image (85).png

Zero-Knowledge (ZK) Rollups and Validity Proofs:

In contrast, ZK-Rollups use a sophisticated cryptographic technique called Zero-Knowledge Proof, usually a form known as ZK-SNARK (Zero-Knowledge Succinct Non-Interactive Argument of Knowledge). Each transaction batch in a ZK-Rollup includes a ZK-SNARK, which provides cryptographic proof that the post-state root is the correct outcome of the batch's execution. This proof can be verified swiftly on the blockchain, regardless of the computation's complexity.

image (86).png

The advantage of ZK-Rollups lies in their speed and security, as they validate transactions efficiently while maintaining privacy. Furthermore, they facilitate quicker fund withdrawals compared to Optimistic Rollups. Recent advancements are leading to the development of zkEVMs (Zero-Knowledge Ethereum Virtual Machines). These zkEVMs aim to replicate the functionality of Ethereum’s mainnet, allowing a broader range of applications to operate faster and more cost-effectively.

Alice and Bob demystify ZK Proofs

Zero-knowledge proof is a groundbreaking cryptographic concept developed by researchers Silvio Micali, Shafi Goldwasser, and Charles Rackoff in the 1980s. At its core, Zero-Knowledge Proof is a method through which one party (the Prover) can convincingly demonstrate the truth of a statement to another party (the Verifier), without revealing any additional information beyond the validity of the statement itself. This revolutionary technique enables the Prover to validate their knowledge or possession of certain data without exposing the data itself. In essence, Zero-Knowledge Proofs are about verifying the accuracy of data while maintaining its confidentiality, making them invaluable in situations where privacy and security are paramount.

Candy Example: Understanding ZKP in Practice

To illustrate how Zero-Knowledge Proofs work in a simple, everyday context, let's consider the example of Alice and Bob, who want to know if they received an equal number of candies from their teachers without revealing the actual count to each other. Assume Bob received 30 candies, Alice got 20, and they both know the total count is no more than 35.

Here's how they use Zero-Knowledge Proof:

  1. Bob is alone in a room with 35 boxes, each labelled from 1 to 35, and he has a key for each box. He discards all keys except for the one belonging to box 30.

  2. Bob leaves, and Alice enters the room. If the number on the box matches the number of candies she received, she slips a "+" chit into the box; if not, a "-" chit.

  3. After Alice leaves, Bob re-enters and opens box 30. He finds a "-" chit, indicating that the number of candies Alice received is not 30.

  4. When Bob exits with the "-" chit, Alice also confirms that they don't have the same number of candies.

In this scenario, Bob and Alice used a Zero-Knowledge Proof to determine they did not receive the same number of candies without revealing the actual number they each received. This analogy beautifully captures the essence of ZKPs - enabling verification without compromising on privacy.

zkSNARK vs zkSTARK

SNARKs (Zero-Knowledge Succinct Non-Interactive Argument of Knowledge) are cryptographic proofs recognized for their small size and quick verification process. They utilize elliptic curve cryptography (ECC), a method based on the challenging task of finding the discrete logarithm of an elliptic curve element. A notable aspect of SNARKs is their need for a "trusted setup." This setup involves someone initially generating the keys used to construct the proofs. While this makes SNARKs efficient and fast in verification, the trusted setup introduces a potential security risk—if these initial parameters are compromised, it could lead to security breaches. Despite concerns over quantum resistance, SNARKs' efficiency and early development have led to their widespread adoption in projects like Zcash and Loopring.

STARKs (Zero-Knowledge Scalable Transparent Argument of Knowledge), developed more recently, use hash functions instead of elliptic curves, providing quantum resistance and eliminating the need for a trusted setup. This makes STARKs more secure in certain respects but also results in larger proof sizes and longer verification times, increasing gas consumption. Although STARKs offer notable security benefits and scalability, their adoption has been slower compared to SNARKs, partly due to less available developer support and documentation. However, they are gaining attention, with significant support from entities like the Ethereum Foundation.

Comparing SNARKs and STARKs

When comparing SNARKs and STARKs, key differences emerge. SNARKs, with their smaller proof size and faster verification, are more efficient for applications where speed and gas cost are crucial. However, their reliance on a trusted setup and vulnerability to potential quantum attacks are significant drawbacks. STARKs, being quantum-resistant and not requiring a trusted setup, offer enhanced security, but at the expense of larger proofs and higher gas requirements. The choice between SNARKs and STARKs depends on the balance between efficiency, security, and scalability needs, with ongoing advancements in the field likely to influence their future adoption and development.

zkRollup Applications

Let's explore a few notable projects that leverage the innovative zk-rollup technology to enhance blockchain functionality and efficiency:

zkEVM: Polygon's Ethereum-Compatible Virtual Machine

zkEVM, developed by Polygon, is a zero-knowledge proof-based virtual machine designed to fully emulate the Ethereum Virtual Machine (EVM). This allows for seamless compatibility with Ethereum’s existing protocols and smart contracts. Polygon’s zkEVM facilitates efficient synchronization of state changes between the ZK environment and the Ethereum mainnet, enhancing transaction speed and security. By integrating zero-knowledge rollups, Polygon's zkEVM significantly improves Ethereum's scalability and transaction throughput.

zkSync: Matter Labs' Scalable Ethereum Layer-2 Solution

zkSync, created by Matter Labs, stands out as an Ethereum Layer-2 scaling solution that emphasizes high transaction speed and low gas fees. Unique for its full EVM compatibility, zkSync uses SNARK proofs, enabling developers to easily migrate existing Ethereum smart contracts to this platform. As a ZK-rollup protocol, zkSync offers enhanced scalability and efficiency for Ethereum, making it a viable solution for developers seeking to optimize performance without compromising security.

StarkNet: Starkware's Decentralized ZK-Rollup Platform

StarkNet, developed by Starkware, is a decentralized ZK-rollup operating on the Ethereum network. It's designed to improve scalability for decentralized applications by offloading data processing to off-chain computations. Utilising STARK proofs for transaction validation, StarkNet offers reduced computational requirements and lower gas fees. As a general-purpose smart contract platform, it enables developers to build and deploy applications more efficiently, contributing to the broader adoption and functionality of the Ethereum blockchain.

Conclusion

After reading this article, if you have gained a clearer understanding of what Zero-Knowledge Rollups are, congratulations—we have taken a step together towards improving our blockchain infrastructure. Technologies that are commonplace today were once considered complex, and this is true for rollups as well. Today, ZK-related technology stands at the forefront of blockchain innovation and is poised to play a crucial role in its evolution. If implemented effectively, this might be the solution to a fundamental challenge in blockchain technology: scalability. It is incumbent upon the blockchain community to research, learn, and harness the potential of zkRollups. With articles like this, we aim to contribute to this journey of discovery and advancement.

If you hold cryptocurrency tokens, you can enhance your portfolio by staking to earn rewards. Leverage Luganodes' institutional-grade infrastructure to stake your holdings and create a passive income. Staking with us ensures ease of use, support, and safety while you earn attractive APRs, contributing to the security of various blockchain networks. Learn how to stake your tokens using our comprehensive guides. You can learn more about our staking services on our website, and feel free to contact us for any queries!

About Luganodes

Luganodes is a world-class, Swiss-operated, non-custodial blockchain infrastructure provider that has rapidly gained recognition in the industry for offering institutional-grade services. It was born out of the Lugano Plan B Program, an initiative driven by Tether and the City of Lugano. Luganodes maintains an exceptional 99.9% uptime with round-the-clock monitoring by SRE experts. With support for 40+ PoS networks, it ranks among the top validators on Polygon, Polkadot, Sui, and Tron. Luganodes prioritizes security and compliance, holding the distinction of being one of the first staking providers to adhere to all SOC 2 Type II, GDPR, and ISO 27001 standards as well as offering Chainproof insurance to institutional clients.

Line pattern
© 2024 Luganodes | All rights reserved