Blog
Building infrastructure for zero-knowledge blockchain products: Dysnix—zkSync detailed experience

Building infrastructure for zero-knowledge blockchain products: Dysnix—zkSync detailed experience

Daniel Yavorovych
August 29, 2023

A zero-knowledge (ZK) proof in blockchain

First of all, let’s clarify that any fact or action can be zero-knowledge-prooved. This concept was developed in the early 80s in math papers and then applied in multiple applications, finding its’ best fit in the blockchain area. Here, a zero-knowledge proof (ZKP) refers to a cryptographic method that enables one party to prove the validity of a statement to another party without revealing any of the underlying data, and both sides will be 100% sure that it’s true. 

“Where’s Wally” way to explain the ZKP: You show Wally and even a part of the surroundings (on the right) to your friends which proves you know where he is. But it doesn’t help them to know exactly where Wally is (the full picture on the left).

Here you will find even more ways to understand the ZKP and explain it even to a child. 

This method, if it’s used from A to Z correctly, provides participants with a full pack of blockchain benefits: enhanced security and anonymity, data sensitivity protection, trustlessness, scalability, swiftness, cheapness, and freedom of use. Here are some comments on how ZK proof makes any blockchain a true self:

  • Powering privacy.
    Zero-knowledge proofs enable transactions to be verified without revealing a sender, receiver, or transaction sum. It preserves participants' privacy while still maintaining the integrity and state of the blockchain.
  • Increasing efficiency, reducing required computational resources, and improving scalability.
    By avoiding a rule that every node has to validate every transaction, ZK proofs let certain computations be offloaded to prove the validity of transactions without the need for every node to execute them. Thus, networks process a larger number of transactions without significant increases in resource demands.
  • Variety of proof types for a wide range of applications.
    zk-SNARKs (Zero-Knowledge Succinct Non-Interactive Arguments of Knowledge), zk-STARKs (Zero-Knowledge Scalable Transparent Arguments of Knowledge), SNORK (Succinct Non-interactive Oecumenical (Universal) aRguments of Knowledge), Bulletproofs have various characteristics and applications in anonymous transactions, data verification, verifiable computation, secure smart contracts, and more.
Attributes STARK SNARK SNORK Bulletproof
Trusted setup No Yes Yes No
Post-quantum security Yes No No No
Prove Actual data Actual data Actual data Range
Universality No No Yes No
Prover-verifier Interaction Multiple times Once Once Depends
Prove Size Large Small Small Small
  • Trustlessness in a nutshell.
    ZK proofs maintain the decentralized and trustless nature of blockchains and allow participants to verify the correctness of transactions by themselves.
  • The core for crypto-saturated blockchain projects.
    Implementing ZKPs in blockchain systems is complex and computationally intensive, but possible for expert-level developers like Dysnix. Ensuring the security of the underlying cryptographic protocols, affordable scalability, and stability of the applications are the tasks we cover in the first place.

We have mentioned a few ways of implementing ZK proof in the blockchain, but let’s elaborate some more to give you a bigger picture.

Application domains: In blockchain and beyond

The versatility of this computing method makes it available for all participants of blockchain and solves lots of uncertainties making grey zones more reliable and transparent. And even if it’s super-complex at first glance, it brings the breakthrough in functionality and efficiency of many Web3 or blockchain-powered projects.

ZKP method may bring sufficient change into the social, financial, and political life of humanity if it is implemented properly.

Privacy-preserving transactions

This zero-knowledge proof example enables private transactions on a public blockchain and widens the possibilities for a single person on the scale of blockchain. Privacy-preserved transactions ensure that transaction amounts, sender, receiver addresses, and other sensitive details are confidential while the integrity of the blockchain is maintained.

Identification and authentication

ZK proofs are actively used for building up secure and anonymous authentication methods. This is a reliable and safe method of logging in or signing in without sharing any personal information with the service.

DEXes

Decentralized exchanges can use ZK proofs for enabling atomic swaps, allowing users to trade different cryptocurrencies without the need for a central authority or revealing trade details. More freedom to a single trader!

It’s an excellent place to mention the PancakeSwap DEX platform which is closely familiar with our solutions.

Smart Contracts

Use ZK proofs to validate certain conditions or computations within smart contracts while keeping the underlying data private. No additional parties are needed. 

Off-chain data verification and cross-chain interoperability

You can validate off-chain data and attest to its correctness, allowing blockchain applications to interact with the outside world securely. ZKPs can facilitate trustless interactions between different blockchains, enabling interoperability while preserving privacy.

ZK-powered scalability solutions

This method can enhance blockchain scalability by allowing for the efficient verification of complex computations off-chain while providing concise proof of their correctness.

Cryptocurrencies and token systems

This is literally the main way to enhance the privacy and security of cryptocurrency transactions, such as ensuring the total supply of tokens without revealing individual wallet balances.

Zero-knowledge oracle services

This method can be utilized to create blockchain oracle services that provide accurate off-chain data to smart contracts without revealing the raw data.

Voting mechanisms

Decentralized elections? Mmmm, sounds like democracy! This is the way to defeat corruption with voting by verifiable and anonymous voting systems, ensuring that votes are counted accurately without compromising voter privacy.

Supply chain and provenance 

In governmental auctions that defeat corruptive schemas by design, it’s important to keep sides anonymous, as well as keep the maximum control and strict distribution of responsibilities regarding the quality of the goods. ZK proofs can help verify the authenticity and integrity of goods in supply chains without revealing proprietary information.

Auditing and standard compliance

This method can facilitate audits by demonstrating compliance with certain regulations or rules without exposing sensitive data and the auditors' personas themselves.

Data sharing and aggregation

ZKPs help parties to share aggregated data (e.g., statistics) without revealing individual data points, maintaining privacy while enabling data-driven decisions.

Game theory and incentive mechanisms

ZK proofs can help design incentive mechanisms and games with verifiable outcomes while keeping players' strategies private. This application can be a breakthrough for lots of yet irresolvable challenges.

That’s simply WOW, you might think. The price you pay for this flexibility and universality is the complex math and code work behind it. It requires you not only to understand the concept but to adapt its principles to your reality and make it work under different conditions in the same expected way. 

We’re glad to share some more details on our zkSync case that we have briefly described previously. We are among those few companies in the world who can handle the ZKP-powered product from A to Z creating the best-fitting design and architecture for it.

Building a ZK-powered product on the zkSync example

The zkSync team came up with only an idea and got the full implementation of their intents with the best-fitting technologies and innovative approaches.

About zkSync

Back in 2020, zkSync, one of the first zero-knowledge proof companies,  became a Layer 2 scaling solution for Ethereum that utilized zk-Rollups, a variant of zero-knowledge proofs, to aggregate and compress multiple transactions into a single proof, which is then validated on-chain. This approach significantly enhances Ethereum's transaction throughput and reduces fees—and it was the main value proposition of this project. 

Soon after the launch, zkSync got lots of big fish partners (DEXes, e.g.) and got integrated with more than 200+ Web3 projects. It was easier to delegate any number of transactions to zkSync than to broadcast each transaction to the network, pay fees, wait for validation, etc. All these happen with zero security concerns thanks to core functionality based on the ZKP method.

Meeting the requirements

The solution behind this simple, elegant, and useful platform was based on the architecture created by Dysnix engineers. It consists of:

  • Multiple server clusters powered by Kubernetes that scale according to business metrics of the client's applications;
  • The validating core—for off-chain packing of the unlimited flow of transactions and preparing them for proving on-chain;
  • Connections with the applications and the blockchain.

Now zkSync team has developed the zkSync Era, the reinvented protocol compared to the first version, but on the same infrastructure we made back then, in 2020. It’s great to recall how our infrastructure effort got aligned with the architecture of such a solid solution. 

An example of a similar architecture of the zkEVM Polygon trusted sequencer node.

Looking for the best-matching server solution

After a brief introduction with the goals of our cooperation, we started to negotiate with a few sales representatives of popular underlayers: GCP, AWS, and Azure Cloud. We were looking for a cost-efficient offer of highly available servers that should be accessible in many different variations and for a few hours term: from 10 to 200 by request, depending on the proof load.

And GCP found something to offer for our request. We agreed upon using the spot instances that will be used only for some short time and then get terminated. It was also the cheapest option with no harm to functionality. This server architecture fits our needs perfectly as they were used only on the proving stage of zkSync work. They provide the project with an extremely high throughput.

Challenges of scaling setup

You might have heard about our PredictKube product, which we’ve created based on AI/ML models. We admit that we got inspiration from projects like zkSync for making it.

By the way, you can try it for free.

But the scaling solution we made for zkSync had nothing to do with AI or ML, as we created a solid math model that fit all possible scenarios, without extra effort. It was implemented into the code by the zkSync team and works with no problems till this time. 

But there was a problem. 

We met the throughput limitation of the GCP data center while launching many nodes. In the test environment, everything worked pretty well: upscaling from one to five nodes was smooth. But on the production side, we met the data center limitations, and our nodes were launching extremely long. To solve this issue, our engineers decided to use the S3 protocol applied to GCP Object Storage. 

Thanks to parallelization functions available via the S3 protocol, we managed the data flow via multiple objects and replicas between the data center and our project. Thus we broke through the 60 GB/sec limitation and increased the speed of the new node launch for zkSynс prover. It helped us change the pattern for new nodes bootstrap from iterative, once 5, then other 5, to the explosive one—all we need at once, and for less than a 1-hour period. 

The role of ZK protocol in this project

  1. Security
    Each transaction is safe and cannot be changed after being signed and sent to the zkSync for approval and validation to the block. All that can happen with TX—it can (or can’t) be included in the following block. 
  2. Scalability
    The solution of the math algorithm for scaling covers all the needs of the zkSync. Even the high-volume transaction load won’t affect the way the ZKP method works.
  3. Increased speed
    Because of the high availability and operational capabilities, the validation as a process became a matter of milliseconds for zkSync. That is much, much more than Ethereum itself can offer.
  4. Reduced costs
    Thanks to server architecture hand-picked for the zkSync, they literally offer the best price for transaction validation on the market. With the implementation of such a protocol, the operational costs stay low as well.

Where to start if you want to apply the ZKP method in your app

To domesticate all this prover and verifier story, you have to come up with an idea for implementation. As you see, the domain of application is extremely wide, but still, it doesn’t mean that all these spheres have the best-implemented zero-knowledge-proof blockchain-based solution already. 

Based on the story of zkSync, you see that the right idea has a developmental potential that will nurture your project with new stages and product implementations. 

We hope we managed to explain a zero proof meaning for you. Feel free to ask us for further details!

Daniel Yavorovych
CTO and Co-founder at Dysnix
Brainpower and problem-solver, meditating and mountain hiking.
Copied to Clipboard
Paste it wherever you like