Solana Builders: ZK Compression

Yash DewasthaleYash Dewasthale
6 min read

The Solana blockchain is designed for a high speed, high throughput applications, not speed but its storage costs can quickly become significant challenge for large-scale products. To tackle this issue of non-chain state costs, ZK Compression an innovative solution was introduced that offers more efficient way to manage large numbers of accounts. This article is written to introduce you more about this challenge and its solution: ZK Compression in depth. By the end of this article you will get familiar with What is ZK-Compression? Why we need it? How it leverages Zero-Knowledge Proofs (aka ZKPs), and its impact on state efficiency and composability in Solana ecosystem. We'll also compare ZK Compression with ZK rollups and explore how it's use in Solana is different than that of Ethereum.

Solana and its Key Properties

Before diving into ZK Compression it is import to understand some the key fundamental properties of Solana blockchain that makes it a suitable platform for such innovation.

  1. Synchronous Atomic Composability:

It means that multiple independent Solana programs can interact with each other in a single transaction while guaranteeing that either all the interactions will succeed and returns the result or all will fail. This process insures that all phases of transactions are processed together so you don't up worrying about a partial transaction state.

How it is relevant to ZK compression:

Well here ZK Compression leverages this property by enabling interactions between compressed and non-compressed accounts within the same transaction. For instance, multiple accounts that have been compressed can still maintain atomic interactions with other on-chain accounts without breaking composability. This ensures that compressed data can interact seamlessly with other on-chain programs, facilitating full composability within Solana’s L1 ecosystem.

  1. Concurrency

Solana's architecture is designed in such a way that allows multiple transactions to be processed in a parallel run. This is usually done by Solana's use of "accounts" an an independent state, that allows transactions that can access different accounts to execute simultaneously.

Relevance to this ZK Compression benefits from Solana's concurrent processing by enabling multiple account states to be compressed and managed independently. Compressed accounts can be processed simultaneously in parallel with non-compressed accounts, optimizing overall performance and ensuring that the compression does not become a bottleneck. Concurrency enhances the scalability that ZK Compression seeks to achieve by reducing transaction latency even when interacting with large datasets.

  1. Safety

In Solana safety here means to guarantee that system will always perform in a valid state and will never process any invalid transaction. This ensure zero invalid transaction and hence does not corrupt the blockchain state.

In relevance to this ZK Compression must ensure that compressed data remains secure and valid. The zero-knowledge proofs used to compress account states provide cryptographic assurances that the compressed data corresponds to the correct on-chain state. This maintains Solana’s safety guarantees, ensuring that even when working with compressed data, all transactions remain verifiable and correct.

  1. Liveness

This property ensures that the system continues to process transactions and progress forward, regardless of network conditions or temporary failures.

ZK Compression adds to Solana's liveness by improving the efficiency of state storage and management. By reducing the storage footprint and transaction size, ZK Compression helps ensure that the blockchain continues to function smoothly, even under high load conditions. This means that applications using compressed states can handle large user bases or frequent small transactions without negatively impacting the network's ability to progress.

  1. Censorship Resistance

Censorship resistance ensures that no single entity (or set of entities) can prevent specific transactions from being included in a block or delay them indefinitely. This is very essential feature of decentralized systems, that ensures fair access to the network for all participants.

Now the question arises Why we need ZK Compression? What it was introduced into Solana ecosystem? How it helps and improve Solana blockchain state? Lets understand all of these questions step wise.

Why ZK Compression?

As it is well know that storing data on chain is very expensive, to put this into a wider context lets understand it with a short example.

Drip Haus which was founded by Vibhu Norby, which is a creator platform built upon Solana, that enables artists and creators to distribute digital works, such as art and music, directly to their followers while facilitating payments and tips. On the platform it usually cost users roughly around "70 SOL" to store "10MB" of account data on Solana, which is huge. To resolve this challenge, ZK Compression offers a way to significantly reduce these storage costs by compressing account data off-chain while maintaining a verifiable state on-chain.

By using Zero-Knowledge Proofs, ZK Compression allows developers to prove that a transaction was executed correctly without storing the entire state on-chain. This keeps the state lightweight and accessible while still following Solana’s composability and concurrency principles.

How ZK Compression works?

ZK (Zero-Knowledge) Compression was introduced by Light Protocol in 2021 , which is a mechanism to reduce the on-chain data storage and bandwidth requirements in Solana transactions. To understand ZK Compression properly it's essential to aware about Solana's traditional transaction lifecycle. a Solana program loads the state of all accounts from storage to memory, processes the transaction, and then writes the modified state back to disk. However, with ZK Compression, the accounts' data is passed as part of the transaction payload rather than loaded from disk.

Typical lifecycle of Solana Transaction

  1. 1.Transaction Validation: This step includes verifying the transaction's age, ensuring that it hasn’t been processed before, performing structural verification, gas fee calculations, and signature checks.

  2. 2.Program Execution: The Solana Virtual Machine (SVM) loads the program bytecode and executes the transaction.

  3. 3.Account Loading: Accounts referenced in the transaction are loaded from storage (disk) into memory.

  4. 4.Account Updates: Any modifications to accounts (such as balance updates) are made and saved back to storage.

Following process of ZK Compression

  1. 1.State Compression: Multiple account states are recursively hashed into a compact 32-byte state root. This root is stored on-chain while the detailed account data is stored off-chain in the Solana ledger.

  2. 2.Merkle Proofs and Zero-Knowledge Proofs: To interact with the compressed data, a Merkle proof is generated, which shows that the off-chain data corresponds to the on-chain state root. However, instead of using large proofs that would exceed Solana’s transaction size limit, Groth16 zk-SNARKs (Succinct Non-Interactive Arguments of Knowledge) are used to compress the Merkle proofs into a smaller, constant-sized proof of 128 bytes. This combination of Merkle proofs and ZK-SNARKs is key to making ZK Compression efficient. It allows Solana to maintain full composability with its L1 structure without compromising the speed and cost benefits that Solana provides.

  3. 3.Proof Verification: When a transaction attempts to modify or access a compressed account, it provides a proof that the data aligns with the state root. This proof is verified on-chain, allowing the transaction to proceed if valid.

0
Subscribe to my newsletter

Read articles from Yash Dewasthale directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Yash Dewasthale
Yash Dewasthale