https://github.com/lovesh/libsnark-playground
Learning ZkSNARKs using libsnark
https://github.com/lovesh/libsnark-playground
libsnark mimc zk-snarks zksnarks
Last synced: 2 months ago
JSON representation
Learning ZkSNARKs using libsnark
- Host: GitHub
- URL: https://github.com/lovesh/libsnark-playground
- Owner: lovesh
- Created: 2018-09-17T14:15:46.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-26T15:07:29.000Z (almost 7 years ago)
- Last Synced: 2025-04-05T07:03:33.955Z (6 months ago)
- Topics: libsnark, mimc, zk-snarks, zksnarks
- Language: C++
- Homepage:
- Size: 14.5 MB
- Stars: 12
- Watchers: 2
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Libsnark playground
Playing with Zk-SNARKs. Some of the code taken from libsnark tutorial repositories from [Christian Lundkvist](https://github.com/christianlundkvist/libsnark-tutorial) and [Howard Wu](https://github.com/howardwu/libsnark-tutorial). The latter contains the build instructions.
1. [Example to prove knowledge of factors of a number](src/factorisation.cpp), i.e given a public output `c`, prove the knowledge of 2 numbers `a` and `b` such that `a * b = c`.
2. [Prove the knowledge of pre-image of a sha256 hash](src/sha256.cpp). Uses libsnark's sha256 gadget. Byte representation of inputs and output can be generated using [python helper script](src/generate_sha256_gadget_tests.py). Use the function `short_string_hash` to generate bytes.
3. [MiMC-Fiestel hash pre-image](src/longsightf-gadget.hpp). 2 implementations, [one](https://github.com/josojo/mimcHashTimings) from [josojo](https://github.com/josojo) that does exponentiation (x^3) during round and other does inverse (x^-1) during the round as suggested by [Dmitry Khovratovich](https://github.com/khovratovich)
4. [Shark MiMC](src/sharkmimc.hpp) as suggested by [Dmitry Khovratovich](https://github.com/khovratovich). Contains 2 gadgets, `SharkMimc_cube_gadget` which treats `x^3` as S-box function and `SharkMimc_inverse_gadget` which treats `x^-1` as S-box function.