Skip to content

basest0w/rapidsnark

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rapidsnark

rapid snark is a zkSnark proof generation written in C++ and intel assembly. That generates proofs created in circom and snarkjs very fast.

Dependencies

You should have installed gcc, cmake, libsodium, and gmp (development)

In ubuntu:

sudo apt-get install build-essential cmake libgmp-dev libsodium-dev nasm

Compile prover in standalone mode

npm install
git submodule init
git submodule update
npx task createFieldSources
npx task buildProver

Compile prover in server mode

npm install
git submodule init
git submodule update
npx task createFieldSources
npx task buildPistache
npx task buildProverServer

Building proof

You have a full prover compiled in the build directory.

So you can replace snarkjs command:

snarkjs groth16 prove <circuit.zkey> <witness.wtns> <proof.json> <public.json>

by this one

./build/prover <circuit.zkey> <witness.wtns> <proof.json> <public.json>

Note that the first two arguments are the input files whereas the last two correspond to the output files. It takes the zkey (circuit.zkey) and a witness (witness.wtns) as inputs, and outputs a proof (proof.json) and the public inputs (public.json).

Launch prover in server mode

In server mode, the prover also compiles the inputs to generate a witness.

If your circuit's name is circuit.circom, then you have to generate the C++ binaries using circom (link from circom docs). In the end, you should have two files circuit and circuit.dat.

To launch the server, set two environment variables:

  1. ZKEY: Pointing to the zkey file
  2. WITNESS_BINARIES: Pointing to the folder in which circuit and circuit.dat are present

and run

./build/proverServer

Note 1: Compared to iden3's rapidsnark server, ours is simpler. Their server was designed to work with multiple zkeys, but ours only handles one. However, we found their code to be buggy in how it handles multiple simultaneous requests.

Note 2: Be careful when setting the log level, e.g., DEBUG logs could contain PII. The default is set to INFO.

Benchmark

This prover uses intel assembly with ADX extensions and parallelizes as much as it can the proof generation.

The prover is much faster that snarkjs and faster than bellman.

[TODO] Some comparation tests should be done.

License

rapidsnark is part of the iden3 project copyright 2021 0KIMS association and published with GPL-3 license. Please check the COPYING file for more details.

About

fast zksnark prover

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 92.0%
  • JavaScript 8.0%