# Unveiling Quark Layer
[toc]
## Why do we need a proof verification and aggregation layer for blockchains in the Ethereum ecosystem?
Zero-knowledge (ZK) has seen rapid growth in the last few years, and it will remain closely tied to modern-day cryptography. New developments often happen in zero-knowledge, resulting in the introduction of new proving systems and optimization of existing proving systems.
Ethereum has a limited 30 million gas per block, and each zero-knowledge proof verification will consume gas from 250k to 1 million. Verifying proofs for different zero-knowledge applications will consume more block space, potentially leading to an increase in gas price due to higher demand. Ethereum recently solved a similar problem for rollups by introducing blobs to store the transactional data.
There are no fee markets on Ethereum for various resource usage as Solana does. It would be better to have a separate fee market only for proof verifications and precompile support for more proof verification systems.
The major limitation of Ethereum for verifying zero-knowledge proofs is that it has only optimised for pairing-based verification with precompiles living in the EVM. Hence, verifying pairing-based proofs on Ethereum is cheap, but not all proving systems use pairings. So, for most proving systems, verification on Ethereum turns out to be prohibitively costly, or developers working with non-pairing-based proving systems need to write groth16 or plonk wrappers for those systems, significantly increasing the development time.
Aggregated proofs allow the verification of multiple proofs as a single proof instead of verifying them individually. With proof aggregation, multiple proofs can be verified as a single proof on Ethereum, reducing per-proof verification gas costs. However, for proof aggregation to happen, applications must wait until enough proofs can be aggregated, introducing a tradeoff between cost savings and latency. The cost per proof verification has decreased, but latency has gone considerably higher.
## What is Quark Layer?
The quark layer is a decentralised proof verification and aggregation layer specifically built for verifying zero-knowledge proofs. Quark layer provides near-instant soft cryptoeconomic guarantees and delayed hard cryptographic guarantees on proof verification result(s). It offers a huge UX improvement for any Zero Knowledge application regarding proof verification results and latency. Zero-knowledge applications can now leverage crypto economic guarantees provided by Quarklayer to do on-chain tasks at significantly lower costs.
The quark layer compliments Ethereum in proof verification. After the quark layer, the modular Ethereum ecosystem looks like this:
<p style="text-align: center">
<img src="https://hackmd.io/_uploads/ryDDsggWC.png">
</p>
Though the quark layer fits well in the Ethereum modular map, it is not restricted to only verifying proofs that need to be verified on Ethereum. It uses the same crypto-economic guarantees to complement other blockchains in proof verifications. In general, blockchain VMs are not designed for proof verification. One can think of this as any blockchain using EVM, SVM, CairoVM, or BitVM, can use quark layer to complement zero-knowledge proof verifications.
There are three transaction types on the quark layer.
1. **Register**: Register a ZK application with its supported verifier and metadata.
2. **Register-image**: Register the ELF and proofs along with their respective hash. The ELF will need to be registered only once, while proofs need to be registered every time.
3. **Verify**: Verify the proof when needed.
After being registered on the quark layer, proofs are broadcasted in p2p to validators. Validators verify proofs in each block when the consensus accepts the block. After proofs are verified, validators cast the verification result on-chain within a few blocks. The proof is marked valid, if more than 66% of validators by stake vote as valid(typically in the next few blocks).
The Quark layer will significantly decrease on-chain verification costs for any Zero knowledge app. Development time decreases as the need for specialised wrappers or optimisations for proof verifications on Ethereum does not essentially exist. With new proving systems and optimisations often in ZK space, the quark layer can support verifiers of any proving system and drastically reduce the need to write on-chain verifiers specific to a proving system.
<p style="text-align: center">
<img src="https://hackmd.io/_uploads/ryPxg7gW0.png">
</p>
Typically, the quark layer acts as a zk coprocessor for proof verifications on Ethereum and other blockchains. It supplements them with cost-effective near-instant verification results providing a soft crypto economic and a delayed hard cryptographic guarantee.
The quark layer is a blockchain using Snowman++ consensus. snowman++ offes single slot finality and no block reorgs, enabling instant transmission of proof verification results to the destination chain. Being a chain also provides quark layer with few advantages.
1. Proof applications using the quark layer can have a minimal state. For example, in the case of rollups using the quark layer for fast finality, their state can be tracked for the last n-batches.
2. Store the verified proofs over a period of time.
3. Maintain the history of proof verifications in the state of the quark layer.
### Main components of the quark layer:
i. Hyper-pvzk, a HyperVM built using [HyperSDK](https://github.com/ava-labs/hypersdk), and [Snowman++](https://docs.avax.network/learn/avalanche/avalanche-consensus) for consensus, enables the quark layer to process 50k TPS with single slot finality.
ii. Sausage, an instance verifying proofs and transmitting back results to Hyper-pvzk. Hyper-pvzk and Sausage are tightly integrated and complement to each other in tasks.
iii. Vajra is a set of relayers for transmitting cryptoeconomically guaranteed proof verification results to various blockchains.
iv. Prover Marketplace (not built by the quark layer) for generating aggregated proof verifications that require delayed cryptographic verification. The quark layer may utilise one or a few prover marketplaces to generate aggregated proof verification.
<p style="text-align: center">
<img src="https://hackmd.io/_uploads/r15clxbWC.png">
</p>
### Crytoeconomic vs Cryptographic security.
Cryptographic security is assumed to be a stronger form of security as accepting wrong proof by the verifier is very low, and the chances of generating fake proof that the verifier can accept are also too low. The security level of the cryptographic system depends on the number of bits of security it promises. Typically, most of the ZK systems promise over 96 bits.
Cryptoeconomic security is deemed weaker as there is a possibility that a colluded validator set may attest to invalid data. However, the cost of such collusion in a Proof-of-Stake system depends on the total amount staked by the validators.
Ethereum provides crypto economic guarantees regarding the validity of its state or transaction(s). However, when cryptographic proof gets verified on Ethereum, the overall security (or) validity depends on Ethereum's crypto-economic security guarantees.
### How strong is Quark Layer's crypto economic guarantee?
The cryptoeconomic security of a chain depends on the value staked by the validators and the volatility of the native token of the chain. Quark layer is going to be an Ethereum Restaked Actively validated service. So, the crypto economic guarantee provided by the quark layer will be as strong as the Ethereum validator set. [And attacking the validator set will equal attacking all the AVS restaked alongside the quark layer. (pooled security)]
Although the quark layer is an ETH restaked AVS, it will have its gas token.
### Benefits of having decentralised verifiers.
Having decentralised verifiers run by Ethereum validators gives almost the same security as verifying proofs natively on Ethereum. Due to pooled security, the crypto economic guarantees provided by the quark layer will be as strong as the restaking service.
## How does the Quark Layer work?
The quark layer will have a minimal state per each zk application and programmability on top of it with pre and post-execute invariants using a simple instruction set. ZK applications can choose the mode(s) of proof verification guarantee(s) they want, crypto-economic or both, and the blockchains on which they want their proof verification results.
Not all verifications on the quark layer are intended to be landed on the same blockchain or multiple blockchains. they may be self-contained within the quark layer itself (quark native zk apps).
<p style="text-align: center">
<img src="https://hackmd.io/_uploads/BkVB5MebA.png">
</p>
While crypto economic aggregation is done by aggregating validator's signatures over the transactions, prover marketplaces are used for cryptographic proof aggregation. Proof aggregation happens every few hours. anyone can submit valid proof to the on-chain contracts. If cryptographic proof verification conflicts with crypto-economic proof verification, validators who voted in favor of the result will be slashed.<<>>
Prover marketplace generates proof of verification and posts the aggregated result on the chain; multiple Prover marketplaces may be used depending on the proof verification type.
Some of the instructions from the simple instruction set are:
```te=
isEqual []byte []byte
update slot []byte
transfer address value
if/else
```
## Possibilities unlocked by Quark Layer:
- New settlement layer(Quark layer + DA).
- Fast finality layer for Rollups.
- Interoperability for ZK Rollups.
- Faster ZK Bridges.
- ZK P2P games.
- ZK oracles.
- ZK Storage commitment verification.
- Orchestrator for prover networks(p2p or any).
- Verifiable Machine Learning Inferences.
- ZK Virtual machine computation verification.
- Encrypted mempools.
- Atomic ZK Transactions.
- Storage Proofs.
- Block Builder Proofs.
- ZK TLS.
:::info
:bulb: Apart from the said use cases for blockchains, Quark layer also unlocks:
- Alice and Bob will prove the result of a chess game to claim their reward.
- A defi app using off-chain computing to adjust fees can generate proof for the calculation and verify on the quark layer.
- P2P protocols for payments using zk.
And a lot more...
:::
As the quark layer can maintain state, any zk application can choose only to exist on quark layer. Any proof that needs some record can be verified on the quark layer. One of the interesting example is that proof generation and verification happen on multiple devices on their browsers. However, to keep a record of the proof and result, the proof can get verified on the quark layer.
## Verifiers supported by Quark Layer:
At the moment, the quark layer supports verifiers of
1. Succinctlab's SP1
2. RiscZero's zkvm
3. Polygon's Miden vm
4. A16Z crypto's JOLT
Support for the following verifiers will be added in the coming weeks.
1. Winterfell verifier
2. Cairo verifier
3. Arkworks
4. Plonky2
5. Plonky3
6. Halo2
7. Nova
8. Spartan
9. ZK LLVM
### What is it having SP1, Risc0, Miden and Jolt on board?
SP1, Risc0, and Jolt are open-sourced general-purpose zk VMs using Risc V ISA. These VMs abstract away the complexities of ZK circuit development. So, ZK development will see a Cambrian explosion because of these easy-to-develop circuits. Having verifiers for SP1, Risc0, and Jolt is like supporting the innovation that will happen with them at the very early stage.
Miden VM is built with its own ISA; though not a general-purpose VM, it offers a lot of capabilities like [private accounts](https://0xpolygonmiden.github.io/miden-base/architecture/state.html#account-database) and [notes](https://0xpolygonmiden.github.io/miden-base/architecture/notes.html). We are planning to support private accounts on the quark layer soon.
## The permisionless target(s):
The quark layer is a permissionless blockchain, meaning anyone can verify their proofs on it, provided it supports the necessary verifiers for the proof verification. When creating an application on the quark layer, developers can specify a target blockchain (or multiple blockchains) where the verified proofs should be relayed. This target is typically corresponding to a chain ID. [Vajra](#Main-components-of-the-quark-layer), the relayer can be used to relay crypto economic proofs to any chain by anyone, as well as cryptographic proofs from the prover marketplace.
## Who are the existing players?
Though a few players are in the space, everyone is in their initial phases.
- [Aligned layer](https://alignedlayer.com/) Restaking AVS and proof verification layer.
- [Nebra Zkp](https://www.nebra.one/) Proof aggregation.
- [Gevulot](https://gevulot.com/) Prover network and proof verification.
- [Horizen](https://www.horizen.io/) Proof verification network.
- [Orbiter finance](https://www.orbiter.finance/home) Proof aggregation middle-ware
Quark layer is open-sourced and the code is available on [github](https://github.com/sausaging).