ZK-snarkers and ZkApps
What is a ZK-snark?
In the Mina blockchain, the functions of block production, data verification and data storage are separated. While validators are engaged in block production and archive nodes store historical data, ZK-snarkers (snark workers) proove and validate transaction data by providing ZK-proofs, or ZK-snarks (snark works) for validators. This largely addresses the issue of scalability since you don’t have to run a powerful node that will have to perform all those three functions simultaneously, but rather you select the type of job you want to do in Mina.
ZK-snark is an acronym that stands for Zero-Knowledge Succinct Non-Interactive Argument of Knowledge.
S - Succinct means that the proofs are small and easy to verify even if the concept being proven is complicated!
N - Non-interactive means that we don’t need back-and-forth communication between a prover and a verifier.
AR - Argument is a formalism for talking about these proofs.
K – Knowledge refers to the fact that the prover actually has the evidence themselves.
All ZK-snarks share the following properties:
they don’t leak information;
they are tiny and easy to verify even if the notion being proven is complicated;
they don’t require back and forth communication;
they are proofs of knowledge — the prover must actually know the thing being claimed, not just that it is true.
A ZK-snark is a data set that allows you to check to prove a transaction’s veracity without knowledge of the proposal itself. At a high level, the validity of the blockchain transition sequence is verified using a snark. The blockchain proof then consists of this ZK-snark and omits the detailed list of transaction states as the snark does the verification work. What ZK-snarkers do is that they literally check all states of a transaction and make a snapshot of its first and last states telling a validator that all the rest is verified and OK. Technically this state snapshot is a ZK-snark. This means that the validators don’t have to do the verification job themselves, which saves their CPU efforts and time and may focus solely on block production. That’s also what makes Mina so brief and succinct since the brevity of a snark ensures the brevity of the blockchain.
For more information on ZK-snarker operation please go here.
Why do we need ZK-snarkers?
Mina is known to use ZK-snarkers as a cornerstone element of its business mode. ZK-snarkers help resolve the following issues:
Confidentiality. A ZK-snarker verifies information without revealing it.
Speed. Since a ZK-snarker takes on some functions from a validator, it accelerates the blockchain.
Scalability. Since no CPU efforts are required to produce blocks, there are no substantial limits to expand the blockchain.
Brevity and succinctness. Since ZK-snarkers provide only a small but sufficient portion of information, and archive nodes store the historical data, the blockchain itself doesn’t contain terabytes of data like in Bitcoin.
For more information on ZK-snarker operation please go here.
Do ZK-snarkers operate for free?
No. ZK-snarkers, like validators, charge a fee for their work.
What is a snarketplace?
To enter a transaction in a block, a validator needs to match a transaction with a snark-work. A snarketplace (snarker + marketplace) is an abstraction in Mina - an equivalent to a marketplace - where validators meet ZK-snarkers. At the snarketplace there are 2 pools: the transaction pool and the snark pool. Transactions enter the transaction pool from the Mempool. ZK-snarkers complete ZK-snarks and enter them in the snark pool. Transactions are made for a certain amount. ZK-snarkers charge a snarker fee for their operation. What a validator normally does at the snarketplace to increase its margin is it looks for a transaction for a higher amount and a ZK-snark which was produced for a lower snarker fee. A higher transaction amount means that a validator later will charge more on its validator fee. Simply said, a snarketplace is a space, where all this block production magic is exercised.
For more information on ZK-snarker operation please go here.
Does a validator choose random ZK-snarks at the snarketplace?
Principally, a validator may pick any snarker and any transaction at the snarketplace it wishes. However, it makes sense to maximise margin, so a validator is normally hardwired to select a transaction with a higher amount (which allows to charge a higher validator fee later) and a ZK-snark with a lower snarker fee.
For more information on ZK-snarker operation please go here.
What are ZKapps?
The Mina blockchain is known to use ZK-snarkers to provide proof of transactions for block production. A ZkApp is an attempt to scale ZK-proof off-chain. Using the power of ZK-snarks, ZKapps can prove knowledge without needing to expose all pieces of information. Only the bare minimum of details needs to be shared, no more than is absolutely required, to complete a transaction. You have total control over which data you want to share and under what terms or conditions you want to share it.
All this allows to implement a whole array of use cases where there is a need to provide verification of some information without fully revealing it, that is part of the information is made public, whereas the other part is concealed.
A ZkApp is implemented both on-chain and off-chain. In its off-chain dimension, a ZkApp is a smart contract that has a user interface for interaction. A smart contract is run off-chain, while the result of the verification is put on-chain as a transaction through a special ZkApp account on Mina. For instance, imagine that we need to verify a client’s credit history. A ZkApp runs a smart contract to verify the credit history. The particular data are not revealed, we only see the verification result in the transaction details.
As technological improvements drive ZK-snark proving time down, we’ll see more efficiency improvements with regard to traditional smart contract computations. The small data size also makes it easy to fix bugs and errors.
To learn more about ZkApps and their use cases, please go here. Here you can also find some realizations of ZkApps.
Can you give some real-life examples of how we can use ZKapps in real life?
Zkapps are Mina innovation, and since it’s a novelty, it is not widely adopted yet. However, there are already some real-life examples of ZKapps operation in various fields: banking, security sector, insurance, medicine, voting and polling, etc. Flexergy is a marketplace for energy companies that are centered around green technologies. Mastermind and Cachebox are games built on a ZKapp. Metamask has its own zkApp wallet for interacting with Mina Protocol. Zkapp technology has a great potential, and its brightest days are still to come. For more information on ZKapp use cases please go here.
What are the advantages of ZKapps?
The key advantages of ZKapps are security and privacy. A ZKapp is a smart contract that allows to conceal the information you don’t want to reveal to a third party. If you want to exercise a smart contract securely and privately, a ZKapp is a good choice.
Can a ZKapp prevent data breaches?
In today’s digital world we are increasingly concerned about the element of privacy. Many times, more information is exposed than is required for the most simple transactions, with no expectation that the information will be kept safe. Nothing can give a 100 percent guarantee of data security, however, the high encryption standards that are used by ZKapps, are a serious argument that data breaches are very unlikely.
Can I become a ZK-snarker myself?
Absolutely. In Mina, if you run a node, you can be a validator, a ZK-snarker, a ZKapp node, or an archive node. If you run a validator node, you produce blocks and receive rewards in return. Validators make a profit both on rewards and the validator fee. If you run an archive node, you do nothing but store the blockchain historical data. If you run a ZKapp node, you put the ZKapp transactions from off-chain smart contracts on-chain. If you decide to be a ZK-snarker, though, you need a higher CPU to successfully produce ZK-snarks. Then if you’re lucky enough, validators will choose your ZK-snarks and pay you a snarker fee. For more information on types of accounts and nodes in Mina, please go here.
What are dApps?
Decentralized applications (dApps) are digital applications or programs that exist and run on a blockchain or peer-to-peer (P2P) network of computers instead of a single computer. DApps are outside the purview and control of a single authority. A dApp, for instance, can be a voting platform or a credit organization that maintains its ledger in a blockchain or a decentralized crypto exchange (DEX). All the information about its performance is recorded in a ledger in the form of transactions.
What is Berkeley?
Berkeley is a Testnet for ZkApps, where you can check their functionality.
Are ZK-snarks only used to achieve blockchain succinctness, but not for having private transactions? Is there a technical reason for this choice?
The chain itself is not shielded, but you can build all sorts of ZK-snarks enabled apps (ZkApps) on top, which will share the succinctness and can be private by default, since the mechanism of ZK-proof is universal. What a ZK-snark or a ZkApp guarantees is that the information you wish to conceal will never be revealed to a third party.
Do I understand correctly, that a node has two different parts: the one is a ZK-snark proof, that is of a constant size and it proves that the current state is valid, while the other is the current state (I presume, a Merkle path/tree) itself, that holds all the data last valid state?
Yes, it’s approximately true. Other blockchains expand with the number of transactions that are happening on the blockchain (because they need those to re-run the entire chain and verify the current state), while Mina only grows with the number of accounts, and that's a way more efficient and allows for a wider range of use cases.
Is it correct to say that every completed snark work will be associated with a transaction in a block?
Yes, that’s true. For a transaction to be added in a block by a validator, there should be a snark work that proves that this transaction is valid and correct.
Did Mina also undergo a ceremony like with Z-cash to create the variables for the ZK-snarks?
No, Mina's pickles ZK-snarks do not require a trusted setup like Z-cash or Aleo.