https://github.com/imdea-software/legosnark
C++ codebase for highly composable zkSNARKs with commit-and-prove capabilities.
https://github.com/imdea-software/legosnark
Last synced: 11 months ago
JSON representation
C++ codebase for highly composable zkSNARKs with commit-and-prove capabilities.
- Host: GitHub
- URL: https://github.com/imdea-software/legosnark
- Owner: imdea-software
- License: apache-2.0
- Created: 2019-07-02T11:10:42.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-10-08T20:35:29.000Z (over 5 years ago)
- Last Synced: 2025-06-27T10:05:36.334Z (11 months ago)
- Language: C++
- Homepage:
- Size: 55.7 KB
- Stars: 39
- Watchers: 6
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
LegoSNARK
Composable Commit-and-Prove zkSNARKs
:envelope: + 🧱 + :wrench: → zk🦈
commitments, gadgets and a framework for commit-and-prove zkSNARKs
This codebase is part of the [LegoSNARK paper](https://eprint.iacr.org/2019/142.pdf).
**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](https://eprint.iacr.org/2014/396.pdf)).
**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](https://github.com/kobigurk/legogro16).
## Overview
This repo includes commit-and-prove gadgets for the following relations:
- **matrix multiplication** (CPmmp in paper): [src/examples/matrixsc.cc](src/examples/matrixsc.cc)
- **generalized sumcheck** (CPsc in paper): [src/gadgets/sumcheck.h](src/gadgets/sumcheck.h)
- **"Linking" Pedersen commitments to vectors** in different bases, i.e. showing that they have the same opening (CPlink in paper): [src/examples/cplink.cc](src/examples/cplink.cc)
- **Hadamard product** (CPhad in paper): [src/gadgets/hadamardsc.h](src/gadgets/hadamardsc.h)
It also includes code for:
- **multivariate polynomial commitments** (CPpoly in paper, partly based on an implementation of the scheme in [vSQL](https://web.eecs.umich.edu/~genkin/papers/vsql.pdf) by Yupeng Zhang): [src/gadgets/poly.h](src/gadgets/poly.h)
- an **additional Hadamard product** based on the scheme in [Lipmaa's Commit-and-Prove paper](https://eprint.iacr.org/2014/396.pdf): [src/gadgets/lipmaa.h](src/gadgets/lipmaa.h)
- an **R1CS for matrix multiplication**: [src/examples/legogrothmatrix.cc](src/examples/legogrothmatrix.cc)
## Setup and Building Instructions
First, install the libraries and utilities required by libsnark and legosnark (see [here](https://github.com/scipr-lab/libsnark) 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.:
~~~~~
examples/cplink
~~~~~
## License
This code is licensed under either of the following licenses, at your discretion.
* [Apache License Version 2.0](LICENSE-APACHE)
* [MIT License](LICENSE-MIT)
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.
[legosnark]: https://eprint.iacr.org/2019/142.pdf
## Reference paper
[LegoSNARK: Modular Design and Composition of Succinct Zero-Knowledge Proofs][legosnark]
[Matteo Campanelli](https://www.github.com/matteocam), [Dario Fiore](https://github.com/dariofiore), [Anaïs Querol](https://github.com/querolita)
CCS 2019
## Acknowledgements
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.