MCPcopy Index your code
hub / github.com/Consensys/gnark

github.com/Consensys/gnark @v0.15.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.15.0 ↗ · + Follow
8,507 symbols 42,629 edges 731 files 3,479 documented · 41% updated 1d agov0.15.0 · 2026-05-13★ 1,72466 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

gnark zk-SNARK library

Twitter URL License Go Report Card PkgGoDev [Documentation Status][gnark User Documentation] DOI

High-performance zk-SNARKs in Go.

gnark provides a high-level API to define circuits, then compile, prove, and verify with production-grade proving systems. It is open-source under Apache 2.0 and uses [gnark-crypto] for field arithmetic and cryptographic primitives.

gnark powers Linea zk-rollup. Include your project in known users by opening a PR.

Why gnark

  • Circuit development in idiomatic Go
  • Fast proving and verification backends
  • Reusable standard gadgets in std/
  • Active security and regression testing culture

Useful Links

  • [gnark User Documentation]
  • [gnark Playground]
  • [gnark Issues]
  • gnark Benchmarks 🏁
  • [gnark-announce] - release and security announcements

Quick Start

Requirements

  • Go 1.25+ (module target: go 1.25.7)

Install

go get github.com/consensys/gnark@latest

Run an example

go run ./examples/cubic

To design your first circuit, follow the tutorial in [gnark User Documentation].

Supported Proving Systems and Curves

gnark currently supports:

  • Groth16
  • PLONK

on the following curves:

  • BN254
  • BLS12-381
  • BLS12-377
  • BW6-761

Notes:

  • Solidity verifier export support is curve-dependent (BN254 is the primary target).
  • Serialized formats are not guaranteed to be stable across versions.

GPU Acceleration (Experimental)

gnark includes experimental GPU acceleration through Ingonyama's ICICLE backend for Groth16 on:

  • BN254
  • BLS12-377
  • BLS12-381
  • BW6-761

See accelerated backend documentation and the ICICLE repository.

Example Circuit

The circuit below encodes x**3 + x + 5 == y.

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 {
    X frontend.Variable `gnark:"x"`
    Y frontend.Variable `gnark:",public"`
}

// Define declares the circuit constraints.
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() {
    var circuit CubicCircuit
    ccs, _ := frontend.Compile(ecc.BN254.ScalarField(), r1cs.NewBuilder, &circuit)

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

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

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

Security

gnark and [gnark-crypto] have been extensively audited, but are provided as-is with no guarantees or warranties. In particular, gnark does not guarantee constant-time implementations or side-channel resistance.

Report vulnerabilities via Security Policy. Do not open public issues for security reports.

Published advisories are listed here.

Testing

CI runs formatting, generated-file, lint, and test checks on pull requests and pushes.

Common local commands:

go test -short ./...
go test -tags=release_checks,solccheck .
go test -tags=prover_checks ./test/... ./examples/...
go test -run=NONE -fuzz=FuzzIntcomp -fuzztime=30s ./internal/backend/ioutils
go generate ./...

Audits

Release Notes

See CHANGELOG.md.

Citing

If you use gnark in research, please cite the latest release:

@software{gnark-v0.15.0,
  author       = {Gautam Botrel and
                  Thomas Piellard and
                  Youssef El Housni and
                  Ivo Kubjas and
                  Arya Tabaie and
                  Yao J. Galteland},
  title        = {Consensys/gnark: v0.15.0},
  month        = may,
  year         = 2026,
  publisher    = {Zenodo},
  version      = {v0.15.0},
  doi          = {10.5281/zenodo.5819104},
  url          = {https://doi.org/10.5281/zenodo.5819104}
}

Contributing

See CONTRIBUTING.md and CODE_OF_CONDUCT.md.

Versioning

gnark follows SemVer. Available versions are in tags.

License

Licensed under Apache 2.0 (see LICENSE).

Extension points exported contracts — how you extend this code

Circuit (Interface)
Circuit must be implemented by user-defined circuit. The best way to define a circuit is to define a type which contains [556 …
frontend/circuit.go
Initializable (Interface)
Initializable is an object which knows how to initialize itself when parsed at compile time. This allows to define new [10 …
frontend/schema/leaf.go
Proof (Interface)
Proof represents a Groth16 proof generated by groth16.Prove it's underlying implementation is curve specific (see gnark [20 …
backend/groth16/groth16.go
Proof (Interface)
Proof represents a Plonk proof generated by plonk.Prove it's underlying implementation is curve specific (see gnark/int [20 …
backend/plonk/plonk.go
WriterRawTo (Interface)
WriterRawTo is the interface that wraps the WriteRawTo method. WriteRawTo writes data to w until there's no more data t [24 …
io/io.go
Solver (Interface)
Solver represents the state of a constraint system solver at runtime. Blueprint can interact with this object to perform [8 …
constraint/blueprint.go
FieldHasher (Interface)
FieldHasher hashes inputs into a short digest. This interface mocks [BinaryHasher], but is more suitable in-circuit by a [15 …
std/hash/hash.go
DynamicFieldParams (Interface)
DynamicFieldParams extends the FieldParams interface to allow for limb size and count depending on the native field size [9 …
std/math/emulated/params.go

Core symbols most depended-on inside this repo

Mul
called by 910
std/gkrapi/gkr/types.go
BigInt
called by 795
internal/smallfields/tinyfield/element.go
Add
called by 753
frontend/api.go
Mul
called by 680
frontend/api.go
NewAssert
called by 636
test/assert.go
Sub
called by 631
std/gkrapi/gkr/types.go
Add
called by 611
std/algebra/native/twistededwards/twistededwards.go
AssertIsEqual
called by 486
std/algebra/interfaces.go

Shape

Method 4,001
Function 3,003
Struct 1,254
TypeAlias 111
Interface 86
FuncType 52

Languages

Go100%

Modules by API surface

std/math/emulated/element_test.go144 symbols
std/math/emulated/emparams/emparams.go99 symbols
std/algebra/emulated/sw_emulated/point_test.go82 symbols
profile/internal/graph/graph.go75 symbols
internal/smallfields/tinyfield/element.go71 symbols
std/gkrapi/api_test.go65 symbols
std/algebra/native/sw_bls12377/g1_test.go61 symbols
test/engine.go57 symbols
internal/smallfields/tinyfield/element_test.go57 symbols
constraint/tinyfield/solver.go57 symbols
constraint/koalabear/solver.go57 symbols
constraint/grumpkin/solver.go57 symbols

For agents

$ claude mcp add gnark \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact