“Mastering ZoKrates: Ethereum’s Privacy Toolkit” — Part 1

Pranshu Rastogi
Coinmonks
6 min readMay 1, 2023

--

Privacy and Security have become paramount concerns in today’s era. This guide will be a series of 3 articles to familiarize you with mastering and using the Zokrates toolkit.

Note: To make the best out of this article, feel free to browse the contents and skip the section if you’re already familiarized with the same.

Part 1 of the series Mastering ZoKrates will include:

  1. Introduction to the series
  2. Overview of zkSNARKs and their importance in privacy-preserving applications
  3. Introduction to ZoKrates and its motivation
  4. Background and technical overview of ZoKrates

Introduction to the series:

Welcome, everyone, to this in-depth series of Mastering ZoKrates. We will be moving from 0 to 1, so whether you’re a blockchain enthusiast or simply a curious cat, I’ve got you covered.

  • Privacy is the new Black: In today’s world, we are sharing data, or we can say oversharing data, reclaiming privacy is major concerns, and with the help of zkSNARKs and ZoKrates we’re going to restore that.
  • Adding Invisibility layer: zkSNARKs and ZoKrates will be helping to include the invisibility to our transactions and interactions with Ethereum Blockchain.
  • Transparency in Ethereum is a myth: Public Blockchain seems like an open book, but sometimes we need to record some private information. So, by using zkSNARKs and ZoKrates, we will make Ethereum Blockchain more secure and private than ever before.

In this Part, we will be jumping to:
Intro of zkSNARKs => Intro of ZoKrates => Overview of ZoKrates

If you want to take a step back and take an overview of ZKP, refer to this.

zkSNARKs Effect: Elevating Privacy on Ethereum:

zkSNARKs (Zero-Knowledge Succinct Non-Interactive Arguments of Knowledge) provide an impressive method to validate correct computations without executing them or revealing the details, ensuring you won’t even know what was executed.

This has three main properties:

  • Zero-Knowledge: The prover can demonstrate possession of specific information without revealing the information itself, ensuring privacy.
  • Succinctness: The proof size is relatively small, and the verification process is efficient, enabling practical implementation.
  • Non-Interactive: The proof can be verified without requiring any interaction between the prover and verifier, streamlining the process.

There are four main steps in the zkSNARKs:

  1. Encoding as a polynomial problem: The process of encoding computations into polynomial equations for verification.
  2. Succinctness by random sampling: Choosing a small, random section to verify in order to reduce the time and effort required for verification.
  3. Homomorphic encoding/encryption: Manipulating the contents (performing computations) without seeing the actual data.
  4. Zero Knowledge: Demonstrating possession of specific information without revealing the information itself.

Let’s try to understand them with analogies:

  1. Encoding as a Polynomial Problem: Cooking a Recipe 👨🏼‍🍳

Imagine you want to prove that you cooked a specific recipe correctly without revealing the recipe itself. The process of encoding the computation as a polynomial problem is like converting the recipe into a series of equations that can be verified without giving away the recipe’s details.

2. Succinctness by Random Sampling: Artwork Verification 🎨

Suppose you want to verify that a large artwork is genuine without examining the entire piece. The succinctness achieved through random sampling is like choosing a small, random section of the artwork to inspect. This approach significantly reduces the time and effort required for verification while maintaining high confidence in the artwork’s authenticity.

3. Homomorphic Encoding/Encryption: Locking a Treasure Chest 💎

Homomorphic encoding/encryption is like locking valuable items inside a treasure chest. The prover can manipulate the contents (perform computations) without ever seeing the actual items, just as they can compute encrypted values without knowing the secret evaluation point.

4. Zero Knowledge: A Magician’s Trick 🪄

The zero-knowledge aspect of zkSNARKs is similar to a magician’s trick. The magician convinces the audience that they have performed a seemingly impossible feat without revealing how it was done. In zkSNARKs, the prover obfuscates encrypted values while still allowing the verifier to check their correctness, maintaining the privacy of the underlying data.

Ref: The above explanation reference has been taken from this paper. If you want to dive deep more technical, please refer linked paper.
Thank you Chris 😄

Introduction to ZoKrates and its motivation:

ZoKrates offers a comprehensive solution for integrating zkSNARKs into your Ethereum-based decentralized applications (DApps). This toolkit simplifies the entire process of utilizing verifiable computation in your DApp. From defining your program in a user-friendly, high-level language to generating and verifying proofs of computation within Solidity, ZoKrates has got you covered.

Let me break down the above paragraph for you:

  1. ZoKrates is a helpful tool for adding privacy to Ethereum DApps.
  2. It makes using privacy features easy for developers.
  3. With ZoKrates, you can:
    a. Write your program in simple language (DSL).
    b. Create special privacy proofs.
    c. Check privacy proofs on the Ethereum blockchain.
  4. ZoKrates makes your DApp more private and secure.

For instance, imagine you’re developing a voting DApp that requires secure and anonymous voting. ZoKrates can help you create a privacy-preserving system where voters can prove their eligibility without revealing their identity or the specifics of their vote. By harnessing the power of zkSNARKs with ZoKrates, you can build trust and maintain privacy in your blockchain applications.

But why do we need this? The motivation behind this:

  • Ethereum’s network runs computations on all nodes, leading to high costs, limited complexity, and low privacy.
  • zkSNARKs provide a more cost-effective solution for verifying computations on-chain without revealing sensitive data, but can be difficult to implement.
  • ZoKrates is a toolbox that simplifies the use of zkSNARKs by allowing developers to create off-chain programs and integrate them with the Ethereum blockchain, expanding the potential of their DApps.
  • With ZoKrates, developers can use high-level programming languages to specify their computations, generate proofs of computation, and verify them within the Solidity smart contract language.
  • This increases the privacy and efficiency of DApps, while reducing the costs and limitations associated with on-chain computations.

Background and technical overview of ZoKrates:

Let’s deep dive into some background or history of ZoKrates:

  • ZoKrates was created in 2018 as an open-source toolkit for zkSNARKs on Ethereum.
  • It was developed by Jacob Eberhardt and Alex Gluchowski, who are both Ph.D. students at TU Darmstadt.
  • ZoKrates has undergone several updates since its release, with new features added and bugs fixed.
  • The development team continues to maintain and improve ZoKrates, with the latest stable release being version 0.8.7 as of May 2023.
  • ZoKrates has gained popularity in the Ethereum developer community as a simple and user-friendly way to implement zkSNARKs.
  • The use of ZoKrates has led to the creation of several privacy-preserving DApps.

Some technical aspects of ZoKrates:

  • ZoKrates is a programming toolbox for creating zero-knowledge proofs (ZKPs) using high-level domain-specific language (DSL) programs compiled into circuits.
  • The ZoKrates DSL is similar to C programming and includes variables, loops, and conditional statements.
  • ZoKrates uses libsnark, a C++ zkSNARKs library, for generating proofs and verification keys.
  • ZoKrates supports elliptic curve cryptography, modular arithmetic, hash functions, and other cryptographic operations.
  • ZoKrates uses the Groth16 proof system for fast and efficient ZKP generation and verification.
  • ZoKrates can be integrated with Solidity for privacy-preserving smart contract development on the Ethereum blockchain.
  • ZoKrates is licensed under MIT and is an open-source project open to contributions from the community.

What’s Next?

So, In this part, we have started our journey with ZoKrates and zkSNARKs. In the next part, we will dive deep into features, and its main components: compiler, libraries, and tools. Also, learning how to write code and A-Z of deployment.

Things we are going to learn in this series.

PART 2 : https://pranshurastogi.medium.com/mastering-zokrates-ethereums-privacy-toolkit-part-2-d12f0270771d

PART 3: https://medium.com/coinmonks/mastering-zokrates-ethereums-privacy-toolkit-part-3-8eb2fadb3232

Please let me know if you have any queries, and will be very glad if you can share more information with me. Always happy to learn more, so let’s connect and explore together 🤝🏼 👇🏼
Twitter, Lens, Farcaster — @pranshurastogi,
Linkedin, Github, Youtube

--

--

Pranshu Rastogi
Coinmonks

Blockchain || ZKP || Queerly curious 🧐|| Empathy resonates 💗 || Learn & Grow together