This repository contains a simple example of using zero-knowledge proofs with the gnark
library to prove knowledge of a witness for a cubic equation and then verify the proof. It demonstrates the process of setting up a circuit, compiling it, generating proofs, and verifying them using zk-SNARKs.
- Go (Golang)
github.com/consensys/gnark-crypto/ecc
github.com/consensys/gnark/backend/groth16
github.com/consensys/gnark/frontend
github.com/consensys/gnark/frontend/cs/r1cs
- Clone this repository:
git clone git@github.com:raadhshenshahhaseeb/go-snark.git
- Build and run the
Snark
function:
go mod tidy
go run cmd/main.go
This will compile the circuit, generate a proof, and verify it using zk-SNARKs. The program will output whether the verification succeeded or failed.
The code consists of the following parts:
CircuitCubic
: A struct that defines the circuit constraints for the cubic equation.Define
: A function that declares the circuit constraints based on the provided equation.Snark
: A function that demonstrates the entire process of circuit instantiation, proof generation, and verification.
This project is licensed under the MIT License.
This code is based on the gnark
library example. Credit goes to the gnark
development team for providing the foundation for this example.