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/eccgithub.com/consensys/gnark/backend/groth16github.com/consensys/gnark/frontendgithub.com/consensys/gnark/frontend/cs/r1cs
- Clone this repository:
git clone git@github.com:raadhshenshahhaseeb/go-snark.git- Build and run the
Snarkfunction:
go mod tidy
go run cmd/main.goThis 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.