TensorCash fork of ConsenSys/gnark — pinned zk-SNARK library used in the TensorCash Groth16 KYC/compliance proof workflow.
  • Go 88.4%
  • Go Template 11.6%
Find a file
2026-04-01 12:00:00 +00:00
.chglog Initial public release 2026-04-01 12:00:00 +00:00
.gotestfmt Initial public release 2026-04-01 12:00:00 +00:00
backend Initial public release 2026-04-01 12:00:00 +00:00
constant Initial public release 2026-04-01 12:00:00 +00:00
constraint Initial public release 2026-04-01 12:00:00 +00:00
debug Initial public release 2026-04-01 12:00:00 +00:00
examples Initial public release 2026-04-01 12:00:00 +00:00
frontend Initial public release 2026-04-01 12:00:00 +00:00
internal Initial public release 2026-04-01 12:00:00 +00:00
io Initial public release 2026-04-01 12:00:00 +00:00
logger Initial public release 2026-04-01 12:00:00 +00:00
profile Initial public release 2026-04-01 12:00:00 +00:00
std Initial public release 2026-04-01 12:00:00 +00:00
test Initial public release 2026-04-01 12:00:00 +00:00
.gitignore Initial public release 2026-04-01 12:00:00 +00:00
.gitlint Initial public release 2026-04-01 12:00:00 +00:00
.golangci.yml Initial public release 2026-04-01 12:00:00 +00:00
CHANGELOG.md Initial public release 2026-04-01 12:00:00 +00:00
CITATION.bib Initial public release 2026-04-01 12:00:00 +00:00
CODE_OF_CONDUCT.md Initial public release 2026-04-01 12:00:00 +00:00
CONTRIBUTING.md Initial public release 2026-04-01 12:00:00 +00:00
debug_test.go Initial public release 2026-04-01 12:00:00 +00:00
doc.go Initial public release 2026-04-01 12:00:00 +00:00
go.mod Initial public release 2026-04-01 12:00:00 +00:00
go.sum Initial public release 2026-04-01 12:00:00 +00:00
integration_test.go Initial public release 2026-04-01 12:00:00 +00:00
LICENSE Initial public release 2026-04-01 12:00:00 +00:00
README.md Initial public release 2026-04-01 12:00:00 +00:00
SECURITY.md Initial public release 2026-04-01 12:00:00 +00:00
version_test.go Initial public release 2026-04-01 12:00:00 +00:00

This is a TensorCash fork of ConsenSys/gnark

This repository is part of TensorCash, useful proof-of-work for verifiable AI. TensorCash uses this fork in its Groth16 KYC/compliance proof workflow.

  • What changed: the umbrella KYC prover replaces upstream github.com/consensys/gnark with github.com/tensorcash/gnark (v0.9.1-plain-rangecheck) so TensorCash can pin the exact gnark behaviour needed by its compliance circuits.
  • How it is used: consumed by shared-utils/kyc-prover in the umbrella repository.
  • Contributing: see the umbrella CONTRIBUTING.md.

The original upstream README follows unchanged.


gnark zk-SNARK library

Twitter URL License Go Report Card PkgGoDev Documentation Status DOI

gnark is a fast zk-SNARK library that offers a high-level API to design circuits. The library is open source and developed under the Apache 2.0 license

gnark Users

To get started with gnark and write your first circuit, follow these instructions.

Checkout the online playground to compile circuits and visualize constraint systems.

Warning

gnark has been partially audited and is provided as-is, we make no guarantees or warranties to its safety and reliability. In particular, gnark makes no security guarantees such as constant time implementation or side-channel attack resistance.

gnark and gnark-crypto packages are optimized for 64bits architectures (x86 amd64) and tested on Unix (Linux / macOS).

Issues

gnark issues are tracked in the GitHub issues tab.

To report a security bug, please refer to gnark Security Policy.

If you have any questions, queries or comments, GitHub discussions is the place to find us.

You can also get in touch directly: gnark@consensys.net

Release Notes

Release Notes

Proving schemes and curves

Refer to Proving schemes and curves for more details.

gnark support the following zk-SNARKs:

which can be instantiated with the following curves

  • BN254
  • BLS12-381
  • BLS12-377
  • BW6-761
  • BLS24-315
  • BW6-633
  • BLS24-317

Example

Refer to the gnark User Documentation

Here is what x**3 + x + 5 = y looks like

package main

import (
	"github.com/consensys/gnark-crypto/ecc"
	"github.com/consensys/gnark/backend/groth16"
	"github.com/consensys/gnark/frontend"
	"github.com/consensys/gnark/frontend/cs/r1cs"
)

// CubicCircuit defines a simple circuit
// x**3 + x + 5 == y
type CubicCircuit struct {
	// struct tags on a variable is optional
	// default uses variable name and secret visibility.
	X frontend.Variable `gnark:"x"`
	Y frontend.Variable `gnark:",public"`
}

// Define declares the circuit constraints
// x**3 + x + 5 == y
func (circuit *CubicCircuit) Define(api frontend.API) error {
	x3 := api.Mul(circuit.X, circuit.X, circuit.X)
	api.AssertIsEqual(circuit.Y, api.Add(x3, circuit.X, 5))
	return nil
}

func main() {
	// compiles our circuit into a R1CS
	var circuit CubicCircuit
	ccs, _ := frontend.Compile(ecc.BN254.ScalarField(), r1cs.NewBuilder, &circuit)

	// groth16 zkSNARK: Setup
	pk, vk, _ := groth16.Setup(ccs)

	// witness definition
	assignment := CubicCircuit{X: 3, Y: 35}
	witness, _ := frontend.NewWitness(&assignment, ecc.BN254.ScalarField())
	publicWitness, _ := witness.Public()

	// groth16: Prove & Verify
	proof, _ := groth16.Prove(ccs, pk, witness)
	groth16.Verify(proof, vk, publicWitness)
}

Citing

If you use gnark in your research a citation would be appreciated. Please use the following BibTeX to cite the most recent release.

@software{gnark-v0.9.0,
  author       = {Gautam Botrel and
                  Thomas Piellard and
                  Youssef El Housni and
                  Ivo Kubjas and
                  Arya Tabaie},
  title        = {ConsenSys/gnark: v0.9.0},
  month        = feb,
  year         = 2023,
  publisher    = {Zenodo},
  version      = {v0.9.0},
  doi          = {10.5281/zenodo.5819104},
  url          = {https://doi.org/10.5281/zenodo.5819104}
}

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

This project is licensed under the Apache 2 License - see the LICENSE file for details