RWC 2022: A Novel Application and a Rust Library for zk-SNARKs

Zero-knowledge proofs are one of the core technologies in cryptography which has recently been deployed in a wide range of applications. A zero-knowledge proof system allows a party, the so-called prover, to convince another party, the so-called verifier, about the truth of a statement without leaking any information about the secret information (a.k.a. witness) associated with the statement. For instance, a zero-knowledge proof system allows one to prove that they are an adult (e.g. +18 years old), without leaking any information about their precise birthdate.

An age verification system.

Zero-knowledge Succinct Non-interactive ARguments of Knowledge (zk-SNARKs) are the most efficient family of zero-knowledge proof systems in terms of proof size and verification which are two prominent criteria for large-scale applications. Due to this fact, during the last decade, they have found many interesting applications and are deployed in various practical (privacy-preserving) systems, such as verifiable computations, e-voting systems, privacy-preserving credentials, and cryptocurrencies, smart contract systems, ledger verification systems, and many more.
Yesterday, in the last session of the RWC 2022 conference, there were a few interesting talks about zk-SNARKs. One interesting one was related to the aggregation of the proofs in Groth’s zk-SNARK [Gro16], which was blogged on this page. In this blog post, we present a short overview of the following two talks from the same session:

The first talk introduced a privacy-preserving network policy enforcement protocol based on zk-SNARKs and the second one introduced the Rust library, arkworks, which is a recently-developed library that provides many of the necessary components to program with zkSNARKs and also benchmark different zk-SNARKs.

Zero-Knowledge Middleboxes:

Policy-enforcing middleboxes play a prominent role in inspecting and controlling the traffic of networks, however, they might break the privacy of users. To ensure the privacy of end-users, one solution is to encrypt the traffic and also hide the destinations from all intermediate parties. However, encrypted traffic can also bypass any local network policies! Due to this fact, many internet service providers have lobbied hard against encrypted traffic. Considering the fact that policy-enforcing middleboxes are a fact of life these days, for example, adult content blocking is legally mandated for U.S. K–12 school networks, it seems we need a solution that besides enforcing the policy of the network, can also protect the users’ privacy.

In this presentation, the authors presented a new solution for the privacy-vs-policy conflict and introduced zero-knowledge middleboxes, which allow the users of the network to encrypt their traffic, but enforce to give a zero-knowledge proof, using zk-SNARKs, that their encrypted traffic is compliant with the policy of the network. Due to the zero-knowledge property of the underlying zk-SNARK, the proof would not reveal any information about the users’ communications, while relying on the soundness of the proof system, the users will not be able to convince the middlebox if their traffic is not policy-compliant. 

Zero-Knowledge Middleboxes.

An interesting point about their construction of zero-knowledge middleboxes is that they only need to apply new changes on the client-side, rather than on the standard encryption protocols like HTTPS. Namely, the two-party zero-knowledge proof generation and proof verification will happen only between the clients and their local networks, and the encrypted-communication protocols (e.g. TLS 1.3) will remain unmodified. More precisely, the clients will encrypt their traffic and will append a zero-knowledge proof, generated by zk-SNARKs, attesting that their plaintext traffic is compliant with the policy mandated by the middlebox. Consequently, the middlebox will act as a verifier of the proof and will allow sending only traffic whose proofs are valid and pass the proof verification successfully. The structure of their zero-knowledge middlebox protocol is shown in the following figure.

Structure of their zero-knowledge middlebox protocol. The client convinces the middlebox that the message M is policy-compliant without revealing it. The handshake and encryption algorithms are part of the underlying secure channel (such as TLS) [Grubbs et al.].

The authors had to deal with a few challenging issues which are discussed with their solutions in the main paper [Grubbs et al.]. Roughly speaking, it seems their main challenges were with enforcing the client to not encrypt and sending one (non-compliant) plaintext while generating a proof about another (compliant) one and also implementing circuit-unfriendly functionalities inside a circuit. The later challenge mainly comes from the compatibility requirement, as they wanted to keep the standard encryption communication protocol unmodified.

To evaluate the performance of their proposed zero-knowledge middlebox protocol, they have used the xJsnark library (written in Java) to compile their code to a circuit and to prove the statement using Groth’s zk-SNARK [Gro16]. Groth’s zk-SNARK generates proofs less than 200 bytes which can be verified in less than 5 milliseconds, and recently it is proven to satisfy proof randomizability and statement non-malleability (its proofs cannot be changed to prove a new statement) [BKSV21]. Therefore, regardless of the encoded policy the proofs are less than 200 bytes, can be verified in less than 5 milliseconds, and are statement non-malleable. However, it seems the proof generation for a TLS connection can take more than 15 seconds, depending on the policy. The latter needs to be improved further to get practical. Seems it can be improved slightly by using a zero-knowledge proof system that has a faster prover algorithm, however, it will result in larger proofs and slightly slower verifications.
To sum up, it seems zero-knowledge middleboxes are a new application for zk-SNARKs that are worthy of continued research to push privacy-enhancing technologies into new settings. Due to using a non-universal zk-SNARK, in their protocol, the clients and middleboxes require a trusted setup phase which seems can be mitigated by using subversion-resistant [ABLZ17, Bag19] or universal zk-SNARKs [GKM+18].

arkworks: A Rust Ecosystem for Programming zkSNARKs:

Starting from 2013, there have been valuable efforts to write various libraries, written in different programming languages, that would allow using zk-SNARKs in practical systems. The initial open-sourced implementation came with Pinocchio zk-SNARK [PGHR13], which had a nice set of tools and compilers to build a circuit from a C/C++ code, build an intermediate encoding (e.g. R1CS) that can be fed into zk-SNARKs, and finally prove the integrity of the target computation via the Pinocchio zk-SNARK. It was a great step, but still not the most efficient one for practicians. Taking to account the follow-up progresses in constructing new zk-SNARKs and more pairing-friendly elliptic curves, after a while, a new library was proposed, so-called Libsnark, that similarly is written with C++ and allows to generate zero-knowledge proofs with zk-SNARKs, and also includes more efficient popular circuits (e.g. hash functions with a smaller number of non-linear gates) and also a large number of proving schemes. Libsnark provides three options for Elliptic curves (Edwards, BN128, and Alt_BN128) which recent cryptanalysis have downgraded their security level.

Arkworks is a new valuable attempt in this direction to provide a more user-friendly library with the necessary components to program with zk-SNARKs. Similar to a few recent attempts, such as Bellman and ZoKrates, the library arkworks is written in Rust, but additionally, it comes with some user-friendly properties that can make it more popular.

arkworks library.

One key feature of arkworks is that many of the necessary components (e.g. implementations of finite fields, elliptic curves, and pairings, along with instantiations of widely-used curves) are packed into generic and easy-to-use modules, The library currently provides the implementation of two non-universal zk-SNARKs [Gro16, GM17] as well as one universal one [Marlin]. Recently, we also implemented our new version of Groth’s zk-SNARK [ABPR21] in arkworks which is also available on Github. Unlike the original version, our new variant [ABPR21] additionally guarantees that the proofs are non-malleable which is necessary for some applications.

The modular design of arkworks, allows to improve the components individually and then directly get some gain on the efficiency of other protocols that use those components as a subroutine. The library offers a wide range of popular Elliptic curves such as BLS12-381, BLS-377, MNT-4-298, MNT6-298, MNT-753, MNT6-753, and BN254 which are deployed in various practical protocols (see figure below).

Elliptic curves in arkworks and some known protocols that use them.

This modular design of the library also makes the benchmarking and comparisons of zk-SNARKs or other primitives much easier than before. For instance, in order to switch between various curves (e.g. in the case of using Groth’s zk-SNARK or Schnorr protocol), various proof systems [Gro16, GM17, Marlin], or various polynomial commitment schemes one can simply act as the following pictures,

Switching between elliptic curves in arkworks.
Switching between proof systems and polynomial commitment schemes in arkworks.

Based on the presented benchmarks in the presentation, it seems the performance of arkworks for doing the common operations required in zk-SNARKs (e.g. multiplication, pairing, etc) is even better than the other Rust-based library Bellman.
To sum up, it seems the composable nature of arkworks provides a set of useful libraries that can be very helpful for engineers and developers who need to build new protocols using zk-SNARKs, and also the researchers who aim to quickly implement and benchmark their new constructions for zk-SNARKs.


RWC 2022, Amsterdam
Karim Baghery