🎨 Detailed Zero Knowledge and Layer 2 Guide 🎃

Hello everyone😊
My name is Elif Hilal! 🔮 I have been working on Blockchain for years. Again, again and again, I’m back with another post! First of all, thank you for reading my articles. If some do not know me or have heard my name for the first time, I will leave a link here to introduce myself.
Now, without further ado, I will summarize what is in the content of this article:
It took time to write all of them, but feel free to contact me if there is anything unclear 🙂🙂🛠️
Note: My content and opinions are my own and do not represent the companies I work for.
Zero Knowledge Proof⛓️
Sometimes we need to prove that we know some information. But in doing so, we must not disclose that information. Have you ever experienced such a situation? The summary of this situation is hidden in the zero-knowledge proof algorithm, which we call ZK.🚨
Zero-Knowledge Evidence means that one party knows a piece of information without disclosing actual underlying information to the other party; It is a cryptographically proven method.
Zero-knowledge proofs were first conceptualized in a 1989 paper by MIT and University of Toronto professors Shafi Goldwasser, Silvio Micali and Charles Rackoff. Their work addressed a class of problems relevant to interactive proof systems in which a “prover” sends messages to a “verifier” to convince the verifier that a mathematical statement is true.🚨

🪂 Goldwasser et al. (1989) focused on the reliability of the verifier rather than the proof. The authors are particularly interested in how to prove something by providing the verifier with the absolute minimum amount of information necessary to validate the proof.
More specifically, a zero-knowledge protocol must satisfy all three properties:
🔴 - Completeness: if a statement is true, an honest verifier will be convinced by an honest prover.
🔴 - Soundness: if a statement is false, a dishonest prover can convince the verifier that it is true only with some very small probability.
🔴 - Zero-knowledge: if a statement is true, a cheating verifier cannot learn any more information than the fact is in-fact true.
Today, there are various ZKP implementations, including zk-SNARKS, zk-STARKS, PLONK, and Bulletproofs, each with their own proof-of-transaction size, proof-of-proof, validation time, and more, working with different mechanisms in their systems.

We will examine these projects in detail below:
🟣 A Detailed Look at Zero-Knowledge 👀
In a given general function, for the value of x and y, the zero-knowledge proof protocol allows one party (known as a proofer) to show a validator that it knows some of x such that f(x; y)=1 without disclosing the value of x. This is the math of the process.
🟢 For example, the following Mandarin or Orange ZKP protocol allows the prover to show that she/he knows how to distinguish between Mandarin and Orange, without explaining how:
The above ZKP protocol doesn’t necessarily have to be logical or very useful; the summary is clear! Isn’t it? :)
📝 Non-Interactive Zero-Knowledge (NIZK) 👻
Traditionally, many ZKP protocols can be made non-interactive (this is called Non-Interactive Zero-Knowledge, NIZK ie). This means that the prover only needs to run a program that takes (f, x, y) as input and outputs the pi proof. With (f, y, pi), any verifier can verify this and be convinced that the prover really knows x without seeing it.
🔒 Simply put, the workflow of a NIZK is similar to a digital signature🔑:
🔐The signer signs a public document using the private signing key and creates a signature. Any authenticator with the document, signature and verification key can check the validity of the signature.🔐
🎲 NIZKs have also found many applications in the blockchain field due to their easy and confidential transferability:
NIZKs with very little evidence are generally classified as zk-SNARKs.
🎲 They are particularly suitable for open systems where many validators may be interested in checking the evidence. In this case, the proof only needs to be calculated once and cheaply verified by many validators.
However, these advantages of ZK come with some disadvantages, such as:
The two parties had to communicate in rounds, with information flowing in both directions throughout the protocol. This is an interaction.
Outside the ZK domain, interactive protocols are widely used in practice. For example, one could run an interactive zk protocol to authenticate a user via password:
📌 An interactive zk protocol allows a server-generated nonce, thus preventing replay attacks (attacks such as the attacker intercepting the message and then resending it to the server for authentication).
📌📌📌Remember, if password authentication consists only of a single message from the client to the server, it is very important to allow a range of interactions, as it will be much more difficult to prevent replay attacks.🔫🔫🔫
📌 🧶 Interactive ZKP is a broader set of protocols that usually includes NIZK protocols (in particular, interaction can always be added to convert a NIZK into an interactive ZKP). However, interaction can lead to features that concise NIZKs do not exhibit, such as high scalability to very large expressions, inexpensive computation, reliable installation avoidance, and minimal memory usage.
NOTE: Zero-knowledge blockchain is a subset of cryptography that helps projects overcome the scaling and privacy limitations inherent to many layer-1 blockchains.🧶
🎨 Now the color is changing. Because the concept of Layer 1 comes into play. If there is Layer 1, there is also Layer 2, right? :)
Layer 2 🕹️
Layer 2 refers to any off-chain network, system or technology built on top of a blockchain that helps extend the capabilities of the underlying layer network. Layer-2 networks can support any blockchain to provide enhancements and updates such as higher throughput.
🧵One of the key requirements for a network, system or technology to be considered layer 2 is that it has the security of the blockchain it is built on.💯
💯 Side chains are generally not considered layer 2 because they often use their own consensus mechanisms and validators, resulting in a different set of security guarantees than the base layer chain.
For blockchains that compromise scalability to achieve greater decentralization and security, layer 2s provide higher transaction throughput, resulting in lower fees. Layer-2s is seen as a great solution to the scalability problem.🧵
📌 🧵Why Do We Need Layer 2? Or do we need it? 📽️
Since the advent of blockchain technology in 2008, thousands of researchers and developers have focused on blockchain scalability issues to keep up with this technology. These limitations have historically resulted in high fees and slow implementation times, reducing the ability of blockchains to operate at scale.
🔱 The blockchain scalability trilemma (blockchain trilemma), put forward by Ethereum Co-Founder Vitalik Buterin, suggests that blockchains cannot scale effectively while keeping the underlying network secure and decentralized. Instead, he says, trade-offs must be made between these three attributes, with the conclusion that today’s blockchain networks can meet two of the three conditions but not all three at the same time.🎨

🔱 Let’s take a look at the event here. Today, blockchains perform three basic tasks.
1- 🎨 Execution
2- 🎨 Data availability
3- 🎨 Consensus
Let’s look at the details now; what are they?

📌 How Do Layer 2 Solutions Work?🎨 😉
There is a situation that I would like to point out here. Blockchain is still not perfectly viable for all systems, yet Layer 2 solutions are not 100% efficient anyway. The Layer 2 concept, which is still in its infancy and development stage, will be explained more clearly in the next few years and will appear with use cases.
🎨 Layer-2s typically have two parts:
1️⃣ A network that processes and executes transactions
2️⃣ A smart contract on the underlying blockchain that resolves any conflict and achieves consensus on the state of the layer-2 network by pasting it into an underlying blockchain
Layer-2 networks are where transactions and computations are performed quickly.📣
Whatever Layer-2 environment is in question, the common denominator between them is; that layer 2s on the underlying chain should provide some sort of cryptographic and verifiable “proof” about the integrity of the proposed state change to the blockchain, either preemptively or retrospectively.
🎨 Similarly, the underlying smart contract implementation may vary between layer 2, but the core functions of the smart contract are always:
✅ Holding and releasing funds transferred to Layer 2 ✅ One type of proof created by layer 2 is to receive, approve, resolve disputes, and then finalize transactions
One of the best ways to conceptualize these two dynamics is to take two examples from existing layer-2 implementations:
Both rollups and payment channels are layer-2 scaling solutions for blockchains, which aim to reduce transaction costs and increase scalability by enabling off-chain transactions. However, there are some key differences!
📌What About Payment Channels?🎶
A payment channel provides an off-chain transfer of on-chain tokens between two or more users with the liquidity pre-funding a channel.

Here’s an example of how payment channels work in a blockchain:
Let’s say Alice wants to buy some digital content from Bob, who is a content creator. They decide to use a payment channel to conduct their transaction.
By using a payment channel, Alice and Bob were able to conduct multiple transactions off-chain, without incurring the high transaction fees and slow confirmation times of the main blockchain. Payment channels can be particularly useful for micropayments and frequent, small transactions, such as those required for gaming or streaming platforms.
✔️ The result of this system is that Bob and Alice only need to pay for two on-chain transactions to open and close the payment channel. With the payment channel open, millions of direct peer-to-peer transfers can be made at zero cost and sub-second speeds; this is a classic example of scalability.
📌 What Are Rollups? 💬
Optimistic rollups and zero-knowledge rollups offer higher throughput and lower costs by executing smart contract state changes off-chain and proving them on-chain. Scalability in rollups is achieved in the following three ways:
➡️ Rollups perform off-chain execution of transactions and requires only small proof execution of the underlying blockchain to verify network activity and store raw transaction data. ➡️ Rollups aggregate batch transaction data when it is sent to a blockchain, so the on-chain gas cost is distributed among a number of transactions. ➡️ Rollups only require at least one honest validator to validate transactions on the base layer blockchain, allowing for smaller validator sets and increased hardware requirements without significantly compromising security.
Here’s an example of how rollups work in a blockchain:
Suppose that there is a decentralized exchange (DEX) on the Ethereum blockchain that allows users to trade various tokens with each other.
However, as the number of users on the DEX grows, so do the transaction fees, as every trade requires a transaction on the Ethereum network.
This can lead to high fees and slow transaction processing times. To address this problem, the DEX could implement a rollup solution:
For example, let’s say 10 transactions need to be processed on the DEX. Rather than broadcasting each transaction individually to the Ethereum network, the rollup solution would bundle them together into a single transaction, known as a “commitment transaction.” This commitment transaction is then posted on the Ethereum network, but with much lower transaction fees than if each of the individual transactions had been posted separately.
The rollup solution processes the individual trades and updates the balances of the traders. These trades and balances are kept in a separate data structure, known as the “rollup state.” The rollup state can be updated many times per second since the slow speed and high fees of the Ethereum network do not constrain it.
This allows anyone on the Ethereum network to verify that the rollup state is correct. The final state of the rollup state is then settled on the Ethereum network by posting a “withdrawal transaction” that distributes the funds to the traders.
🏁 By using a rollup solution, the DEX can greatly reduce the transaction fees and increase the transaction processing speed for its users. Furthermore, the rollup solution is secured by the Ethereum blockchain, so users can trust that their funds are safe and that the trades they make on the DEX are valid.
NOTE : Optimistic Rollups is an alternative layer-2 technology used by leading scaling solutions.
What are Zero-Knowledge Based Solutions?😗

🧵 ZK-Rollups!
ZK-Rollups! It is an L2 scaling solution that performs off-chain computation and storage where all funds are held by a smart contract on the main chain, sidechains are validated with zero knowledge proofs.
Zero knowledge-rollups aggregate many transactions and send them to the layer 1 blockchain with proof that validates this calculation.
Evidence published in the chain is known as validity proofs and can be “SNARK” or “STARK”. When this evidence is validated on the layer-1 blockchain, zero knowledge rollups move to a new state.
When you see rollups, don’t immediately think of them as zk-Rollups, it can be optimistic- rollup! They are different from each other. A Rollup is an off-chain aggregate of transactions in an Ethereum smart contract, reducing fees and congestion by increasing the blockchain throughput from the current 15 tps to over 1000 tps. Optimistic Rollups can support both simple payments and complex smart contracts, where 80% of Ethereum Virtual Machine (EVM) tools can be transferred.
📌 Validium
Validiums combine validity proofs with off-chain data storage to increase scalability.
While data is stored off-chain, proofs of validity continue to be published on the main chain. This significantly increases efficiency and reduces gas costs.
While this is a much more efficient and scalable architecture than zk-rollups, it does run the risk of malicious actors making data unusable and unable to withdraw users’ funds. This data availability issue is overcome with proof-of-stake type systems that use crypto economic incentives to help ensure that data is stored by many nodes and always available. It is important to note that while these malicious actors can stop transactions, they cannot directly steal user funds.
📌 Volitions🧵
Volitions combine both zk-rollups and validiums and allow users to choose between both scaling solutions as they share a single state root. Even if there is a successful malicious attack on the validium side of the request, the funds on the zk-rollup side will still be safe.
📌 Layer 2 Security: How Important Is Evidence? ⚙
The concept of “proof” is fundamental to layer 2's for security guarantees of a base chain. In the physical world, proof can take various forms. Fingerprints on the gun and camera records at the time of the incident constitute evidence as we all know.📊
📌🟣 Cryptographic evidence works similarly, but the contents are much more objective than is accepted in physical courts.⚒
Proving something with cryptography gives objective, verifiable, and tamper-proof guarantees that something certain is true. If the proof works, it’s guaranteed to be true. Regarding payment channels, cryptographic signatures in transactions provide the exact truth that the smart contract needs to resolve any dispute.⚒
💊 Optimistic Rollup Fault Proofs 🕘
Error proofs are simple. A layer 2 using fault proofs acts on the assumption that all transactions are valid by default. However, there is a dispute period when any network participant can create a dispute and prove to the smart contract that the transaction data and the proposed state change are incorrect.
When a proof of error is published, the rollup operation is partially or completely re-executed on the chain, and the resulting state change is compared to the original request. If the re-execution results in a different result, the original claim is invalidated and withdrawn.
This system is used by optimistic rollups today. The “optimistic” philosophical perspective actually comes from error protection:
📌 The smart contract “optimistically” assumes that all transactions are valid until proven otherwise (everyone is innocent until proven guilty).
As we already know, Optimistic Rollup (OR) is a layer-2 scaling solution for blockchains that allows for fast and cheap transactions, while maintaining the security and decentralization of the underlying blockchain.
One of the key features of Optimistic Rollups is its ability to provide “optimistic” finality of transactions, which means that transactions are assumed to be valid unless proven otherwise. This approach is much faster and cheaper than the traditional “pessimistic” approach, which requires every transaction to be checked by the blockchain, but it also introduces the possibility of fraud.
✔ However, there are some cases where fraud proofs can fail, which is known as “faulty fraud proof.” This can occur, for example, if the data used in the fraud proof is incorrect, or if the proof is submitted too late. To address this issue, Optimistic Rollup also includes a mechanism called “optimistic rollup fault proofs,” which are designed to provide additional guarantees of the system's security.

🔵 ZK-Rollup Validity Proofs🧵
ZK-Rollup is a layer-2 scaling solution for blockchains that uses zero-knowledge proofs to provide a high level of scalability and privacy.
✅ The key feature of ZK-Rollup is the ability to bundle many transactions into a single proof, which can then be submitted to the blockchain, reducing the overall cost and increasing the throughput of transactions.
✅ Simply put, proofs of validity prove that something is true. Yes, that’s how it is. In the case of a zk rollup, this necessarily refers to operations and computations taking place in the layer-2 network. The corresponding on-chain smart contract can verify the validity proof of layer 2 to confirm state changes.
In the context of validators, a fully functioning zk rollup effectively makes it impossible for erroneous or malicious transactions to be resolved on the underlying chain, as each party must have a corresponding proof of validity.📤📥
✅ To ensure the validity of these bundled transactions, ZK-Rollup uses a mechanism known as “ZK-Rollup Validity Proofs.”
These are mathematical proofs that demonstrate that the bundled transactions are valid and comply with the rules of the blockchain. Validity proofs are generated off-chain by the ZK-Rollup operator and then submitted to the blockchain as a single transaction.
📚 The ZK-Rollup Validity Proofs work by using a zero-knowledge proof system that allows the operator to demonstrate that they have correctly executed the bundled transactions without revealing any of the details of those transactions. This means that the privacy of the underlying transactions is maintained while ensuring that they are valid and comply with the rules of the blockchain.
📚 Overall, ZK-Rollup Validity Proofs help to ensure the security and scalability of the ZK-Rollup system by allowing for the bundling of many transactions into a single proof while maintaining the validity and privacy of those transactions.

✌🏻 Validity Proofs ✌🏻
📌 SNARKs
SNARK stands for “zero-knowledge, concise, non-interactive argument over knowledge”!
Zero Knowledge Succinct Non-interactive Argument of Knowledge : ZK-SNARK
SNARK is a type of cryptographic proof that is small in size and easy to verify. SNARKs generate a cryptographic proof using elliptic curves, which assumes that it is not possible to find the discrete logarithm of an arbitrary elliptic curve element from a generally known base point. Calculating elliptic curves is computationally cheaper than calculating hash functions used by STARKs, so that SNARK-based protocols can be more gas-efficient.
Transactions are pooled together, signed for the main chain, and committed by header only. Therefore, the amount of data stored on the Ethereum chain is reduced. All signatures are replaced with a zero-knowledge proof, known as ZK-SNARK, which allows for the compression of batches.
The first zero-knowledge proofs identified were introduced in the late 1980s by Goldwasser, Micali, and Rackoff4, but modern development of zk-SNARKs has only taken place in the last decade (by Alessandro Chiesa, professor at UC Berkeley), and this technology is continually being improved.. Zk-SNARKs (Zero Information Succinct and Non-Interactive Information Argument) are particularly “concise” zero-knowledge proofs, meaning they can be verified in milliseconds with a proof length of several hundred bytes.
In summary, we can say that a SNARK is a “Concise Non-Interactive Information Argument” which refers to a structure of evidence in which it can be proven that it has specific information (for example, a secret key) without disclosing that information and without any interaction between the prover and verifier.👈🏻
📌 STARKS🧵
STARKS stands for “zero information scalable transparent information argument”.
Zero-knowledge scalable transparent argument of knowledge
It is a type of cryptographic proof that requires little or no interaction between the prover and the verifier (prover and verifier).
The most important advantages of STARKs over SNARKs are that they have fast proving times and are easier to scale because they offer more computing power. Also, using hash functions makes them quantum resistant.
Small note: STARKs were invented by Eli Ben-Sasson, co-founder of StarkWare, the team that created StarkEx and StarkNet.

🟥 SUMMARY 🥰
🙂 Scaling on Blockchains ♥️
Payment channels, rollups, and, more broadly, layer 2s are methods of approaching the blockchain scalability issue in a sustainable and long-term focused way, supporting both Web3 application adoption and enhanced user experience.
🟢 As an emerging technology, most Web3 infrastructure components, including underlying blockchains and layer 2s, have yet to reach the inflection point where the best approach to market needs is known for certain.
📌 You read it right, it is still being worked on, but there is no one hundred percent systematic perfection. 🗯
🟢 However, thousands of developers and researchers continue to work to find viable solutions through the vast blockchain networks, DAG solutions and layer 2 ecosystem that exist today to bring the promise of Web3 to the forefront of society.
But I can tell you that 2023 seems to be the year of ZK-Rollups, Optimistic Rollups and Layer 2 solutions. :) Let’s see!📚

📚 See you 🌻 👋🏻
To learn more about the differences between Optimistic rollups and zero-knowledge protocols, you can watch this latest video on the future of Ethereum layer 2 with the leaders of Offchain Labs, Polygon Hermez, Matter Labs, Metis DAO, and Optimism that we recorded in Amsterdam :

🧠 💻 By the way, you can sign up for my Meetup page, join my Telegram group, and follow me on Twitter to be informed about the events I organize in the Blockchain ecosystem!👻 I hope my articles and contents are beneficial to you. 🧑🎤👩🏼🎤
Do not hesitate to contact me 😉🎄