Skip to content

duckki/mini-snark

Repository files navigation

mini-SNARK

mini-SNARK is a simple implementation of zk-SNARK protocol. It's implemented in Python and the only external dependency is py-ecc from the Ethereum foundation. I wanted something simpler and easier to understand than the babySNARK. And the goal is to keep the code as simple as possible.

Repo Layout

Math libraries

  • field.py: Implementation of finite field arithmetic and polynomial.
  • bls12.py: A symmetric adaptation of the BLS12-381 curve.

Credit

The BLS12 code is from the babySNARK repo. Also, I took the field.py partially from the stark101 tutorial repo with some modifications.

Polynomial Commitment Scheme (PCS)

KZG is one PCS that is commonly used. I've implemented two versions.

  • kzg-simple.py: A simplified KZG PCS implementation.
  • kzg.py: A reusable implementation of KZG PCS.

The detailed explanation of their implementation is in docs/kzg.md.

Example Applications

Complete examples combining PCS with a simple circuit:

The detailed explanation of their implementation is in docs/example.md.

References

About

A simple SNARK implementation in Python

Topics

Resources

Stars

Watchers

Forks

Languages