This codebase is part of the LegoSNARK paper.
What this codebase includes: example and benchmark implementations in C++17 for some of the schemes in the LegoSNARK paper (plus others, e.g. multivariate polynomial commitments, algorithms for multilinear extensions, a product scheme from eprint:2014/396).
What this codebase is not: it is not for production use; it is not extensively tested; it is not a full-fledged API or EDSL* for commit-and-prove SNARKs.
(*We are still considering an EDSL for commit-and-prove but moved our focus from C++ to Rust as an implementation language as we found the latter to be a superior match)
Looking for LegoGroth16?
If you are looking for LegoGroth16, the commit-and-prove version of Groth16, you can find a Rust implementation here.
This repo includes commit-and-prove gadgets for the following relations:
- matrix multiplication (CPmmp in paper):
- generalized sumcheck (CPsc in paper):
- "Linking" Pedersen commitments to vectors in different bases, i.e. showing that they have the same opening (CPlink in paper):
- Hadamard product (CPhad in paper):
It also includes code for:
- multivariate polynomial commitments (CPpoly in paper, partly based on an implementation of the scheme in vSQL by Yupeng Zhang):
- an additional Hadamard product based on the scheme in Lipmaa's Commit-and-Prove paper:
- an R1CS for matrix multiplication:
Setup and Building Instructions
First, install the libraries and utilities required by libsnark and legosnark (see here for more detailed requirements). On several Ubuntu systems this can be done directly through the following command:
sudo apt-get install build-essential cmake git libgmp3-dev libprocps-dev python-markdown libboost-all-dev libssl-dev
Clone the repo and set up submodules:
git clone https://github.com/imdea-software/legosnark.git cd legosnark git submodule update --init --recursive
Build all dependencies:
mkdir -p build cd build cmake .. cd depends make -j8 sudo make -C libsnark install
To build library and executables:
cd ../src # Assuming you were in build/depends from the steps above make -j8
To try an example, run e.g.:
This code is licensed under either of the following licenses, at your discretion.
Unless you explicitly state otherwise, any contribution that you submit to this library shall be dual licensed as above (as defined in the Apache v2 License), without any additional terms or conditions.
This work has been supported by the Spanish Government under projects Datamantium (ref. RTC-2016-4930-7), SCUM (ref. RTI2018-102043-B-I00), and CRYPTOEPIC (refs. ERC2018-092822, EUR2019-103816), by the Madrid Regional Government under project BLOQUES (ref. S2018/TCS-4339) and by Protocol Labs. The project that gave rise to these results received the support of a fellowship from “la Caixa” Foundation (ID 100010434). The fellowship code is LCF/BQ/ES18/11670018.