Unlocking the Power of Privacy: ZK-SNARKs vs. ZK-STARKs in Blockchain Protocols ๐ŸŒ๐Ÿ”’

Solidity Academy
7 min readOct 16, 2023

ZK-SNARKs vs. ZK-STARKs

In the ever-evolving realm of blockchain technology, zero knowledge proofs have emerged as a powerful cryptographic tool, offering a compelling solution to the long-standing challenges of privacy and scalability. These cryptographic marvels, also known as arguments of knowledge, hold the ability to provide concrete proof that a specific computation yields a particular result while safeguarding the privacy of certain input data. Today, we delve into the fascinating world of zero knowledge proofs, specifically focusing on two groundbreaking protocols: ZK-SNARKs and ZK-STARKs. ๐ŸŒŸ

Photo by Behnam Norouzi on Unsplash

Demystifying Zero Knowledge Proofs ๐Ÿง

Before we embark on this journey to explore the differences between ZK-SNARKs and ZK-STARKs, letโ€™s take a moment to grasp the fundamental concept of zero knowledge proofs. At its core, a zero knowledge protocol allows one party to convincingly demonstrate the validity of a computationโ€™s result without disclosing the actual input data used in that computation. Think of it as proving a secret ingredient in a recipe for a golden crust without revealing the ingredient itself. In the context of blockchain, itโ€™s akin to verifying a nonceโ€™s existence that, when applied to a blockโ€™s header and hashed, yields a specific hash value with a predefined pattern of zeros. This verification happens without requiring all network participants to perform the extensive hashing process or reveal the nonce. The beauty lies in the ability to verify a statement swiftly without divulging the specifics or re-executing the entire process. ๐Ÿฐโ›๏ธ

The Intricate Dance of Mathematics ๐Ÿค“

Zero knowledge proofs are underpinned by intricate mathematical concepts, but weโ€™ll only scratch the surface here. Imagine a complex computation involving input numbers and a million hash iterations. Rather than meticulously inspecting every step, a succinct proof allows verification by randomly sampling a fraction of the components. If these checks pass, we can safely assume the entire computation is correct. This concept is immensely valuable for blockchain technology, offering two primary benefits:

1. Scalability: In scenarios where a computation is time-consuming, such as those involving ZK-SNARKs or ZK-STARKs, only one entity needs to perform the computation and generate proofs. The rest of the network participants can efficiently validate the proof, saving both time and energy. This is especially crucial in addressing the blockchain scalability trilemma.

2. Privacy: By leveraging zero knowledge proofs to conceal computation inputs, transactions can occur with enhanced privacy. This prevents the inadvertent exposure of sensitive information to the public. For instance, you can verify your Ethereum balance for a transaction without revealing the senderโ€™s identity. ๐Ÿ”’๐Ÿ’ฐ

ZK-SNARKs vs. ZK-STARKs: Unveiling the Distinctions ๐Ÿ•ต๏ธโ€โ™‚๏ธ

Our main focus in this article is the comparison between ZK-SNARKs and ZK-STARKs, two stalwarts in the world of zero knowledge proofs. While they both share the goal of efficient and private proof validation, their implementations diverge significantly. Letโ€™s delve into the specifics of each.

What Are ZK-SNARKs? ๐Ÿง

Definition: ZK-SNARKs, or โ€œZero Knowledge Succinct Non-Interactive Argument of Knowledge,โ€ represent cryptographic proofs that allow validation of a claim without reiterating extensive computations while keeping certain inputs confidential.

Inner Workings & Principles: The succinct nature of ZK-SNARKs ensures that the verification process is significantly faster than the actual computation. Achieving this involves techniques like polynomial commitments, implemented through FRI, bulletproofs, and Kate. The crucial feature of ZK-SNARKs is their non-interactive nature, meaning that thereโ€™s no need for constant back-and-forth communication between the prover and verifier. This simplifies the process, requiring just one round of communication. The prover, equipped with a shared key (public parameters), uses an algorithm to generate a zero-knowledge proof based on their secret data. The verifier, in turn, checks this proof using another algorithm. Once established, this proof can be independently verified by anyone with access to the shared key. ๐Ÿ”‘๐Ÿ”„

Importance of a Trusted Setup in ZK-SNARKs: The shared key, referred to as the Common Reference String (CRS), plays a pivotal role in non-interactive proofing. Any compromise in the CRS can open the door for dishonest actors to fabricate false proofs. To mitigate this risk, multi-party computation (MPC) is employed during a trusted setup ceremony. The integrity of the zk-SNARK protocol heavily relies on this phase, necessitating rigorous blockchain protocol audits to ensure a correct execution of the setup. ๐Ÿ•ต๏ธโ€โ™‚๏ธ๐Ÿ”

Applications & Use Cases: ZK-SNARKs found their first practical application in Z.cash, a cryptocurrency that employs ZK-proofs to enhance transaction privacy. ZK-SNARKs have furthered their impact in Layer 2 scalability solutions, prominently featured in ZK-rollups like Loopring, zkSync, ZKSpace, and Aztec, among others. ๐ŸŒ๐Ÿ’ฑ

What Are ZK-STARKs? ๐Ÿค”

Definition: ZK-STARKs, or โ€œZero Knowledge Scalable Transparent Argument of Knowledge,โ€ represent a specialized category of zk-SNARKs. STARK protocols are particularly suited for situations where witnesses are of significant size, and they excel in providing high transparency.

Inner Workings & Principles: ZK-STARKs come with a higher verification overhead compared to zk-SNARKs, but their efficiency shines when dealing with large witnesses. What sets STARKs apart is their independence from a trusted setup. Instead, they use publicly verifiable randomness to generate public parameters, making them a more transparent option when the credibility of the CRS process is in doubt. ๐ŸŒŒ๐Ÿ”Ž

Applications & Use Cases: ZK-STARKs find a home in ZK-rollups, much like their SNARK counterparts. The pioneering project in the realm of zk-STARKs is Starkware, which has developed the ZK-friendly language Cairo and the Starknet layer 2 solution. ๐Ÿš€๐ŸŒ

Comparing ZK-SNARKs vs. ZK-STARKs ๐Ÿง

Letโ€™s break down the key distinctions between these two zero knowledge proof giants:

Proof Size: ZK-SNARKs offer compact proof sizes, making them ideal for EVM data availability. On the other hand, ZK-STARKs come with larger proof sizes, driving up the costs. ๐Ÿ“Š๐Ÿ’ฐ

Trusted Setup: ZK-SNARKs require a trusted setup, a critical step that can pose security risks if not executed correctly. In contrast, ZK-STARKs eliminate the need for a trusted setup, enhancing their resilience. ๐Ÿ”๐Ÿšซ

Verification Time: ZK-SNARKs are known for their fast verification times, while ZK-STARKs achieve faster verification times but primarily with large datasets. ๐Ÿ•’โšก

Quantum Security: ZK-SNARKs are not quantum-resistant, which is a potential vulnerability in the era of quantum computing. ZK-STARKs, however, are designed with quantum resistance in mind. ๐ŸŒŒ๐Ÿ”

Transparency: ZK-SNARKs might be perceived as less transparent due to their reliance on a trusted setup. In contrast, ZK-STARKs are inherently more transparent, relying on public verifiable randomness to establish parameters, ensuring an open and trustless verification process. ๐ŸŒ๐Ÿ”

Scalability: ZK-SNARKs are less scalable, exhibiting linear increases in size with the underlying computation. In contrast, ZK-STARKs are highly scalable, especially when handling extensive data, as their proving and verification times increase at a quasilinear rate. ๐Ÿ“ˆ๐Ÿš€

Use Cases: ZK-SNARKs excel in systems where proof size and speed are paramount. They are well-suited for privacy coins, identity verification, and decentralized finance (DeFi) applications, benefiting from their compact proof sizes and consistent verification times. On the other hand, ZK-STARKs shine where transparency and quantum-resistance are top priorities, making them ideal for Layer-2 solutions. ๐ŸŒ๐Ÿ’Ž

SNARK and STARK in ZK-EVM ๐Ÿš€

An exciting transition in the world of blockchain validation is the emergence of ZK-EVMs (Zero Knowledge Ethereum Virtual Machines). These innovations enable the execution of Ethereum Virtual Machine (EVM) code for layer 2 protocols known as ZK-rollups. Several ZK-EVM projects are already underway, such as the ZK-EVM Community Solution, Polygon zkEVM, ZKSync Era, Scrollโ€™s ZK-EVM, and more. These ZK-EVMs vary in their level of compatibility and equivalence with the EVM, with some permitting a 1:1 EVM compatibility, allowing smart contracts written for Ethereum to be deployed on ZK-EVM-based layer 2 without modification. This integration with the EVM introduces a level of convenience, as developers can continue to use Solidity, Ethereumโ€™s primary programming language, instead of adopting specialized languages for ZK-proofs like Circom and Cairo. Additionally, itโ€™s worth noting that while โ€œzero knowledgeโ€ isnโ€™t explicitly used in existing ZK-Rollups, the concept of succinctness, or computation compression, remains a fundamental driving force in their development. ๐ŸŒ๐Ÿ’ก

Conclusions & Final Thoughts ๐Ÿค”๐ŸŒŸ

In the grand tapestry of blockchain technology, ZK-SNARKs and ZK-STARKs represent pivotal threads, contributing to the realization of efficient and private transactions. These cryptographic tools have the potential to revolutionize scalability and privacy within blockchain systems. Many experts consider ZK-STARKs an improvement over ZK-SNARKs, primarily due to their quantum resistance, scalability, and transparency. However, itโ€™s important to acknowledge that ZK-STARKs come with larger proof sizes and higher costs. Therefore, ZK-SNARKs continue to hold their ground as a practical choice in various applications. As research in this field progresses, both ZK-SNARKs and ZK-STARKs will play instrumental roles in shaping the future of decentralized systems, paving the way for cost-effective, swift, and private transactions. ๐ŸŒŒ๐Ÿค

Resources for Further Exploration ๐Ÿ“š๐Ÿ”

  • Ben-Sasson, E., Bentov, I., Horesh, Y., & Riabzev, M. (2018). โ€œScalable, transparent, and post-quantum secure computational integrity.โ€ Read the paper
  • Buterin, V. (2022). โ€œSome ways to use ZK-SNARKs for privacy.โ€ Explore the article
  • Buterin, V. (2021). โ€œAn approximate introduction to how ZK-SNARKs are possible.โ€ Read the article
  • Ethereum.org (2023). โ€œZero Knowledge Rollups.โ€ Discover more

--

--

Solidity Academy
Solidity Academy

Written by Solidity Academy

Learn smart contract development and blockchain integration in depth. https://heylink.me/solidity/ * For Collaborations solidity101@gmail.com