Skip to content

zk-examples/gnark-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gnark-examples

Layout

  • examples/cubic: the minimal Groth16 reference example.
  • examples/sumproduct: a tiny two-public-signal example for sum and product relations.
  • examples/mimc: native and in-circuit MiMC aligned across BN254 and BLS12-381.
  • examples/merkle: MiMC-based Merkle inclusion proof.
  • examples/eddsa: BLS12-381 EdDSA signature verification.
  • examples/commitments: no commitment, one commitment, and two commitments in one readable package.
  • examples/recursion: explicit Groth16 and PLONK recursion examples, split by backend and curve pairing.
  • internal/curves, internal/proving, internal/nativehash, internal/snarkjs: small internal helpers used across examples.

Commands

go test ./...
go test -tags snarkjs ./examples/... -run SnarkJS -count=1
go test -tags recursion -short ./examples/recursion/...
npm test

For full recursion runs timing commands, see examples/recursion/README.md.

npm test regenerates snarkjs-compatible artifacts and runs a fast smoke test that checks the exported JSON shape. Full cryptographic snarkjs.verify is available separately:

npm run test:snarkjs:full

That full verification path is intentionally opt-in because snarkjs.verify on exported gnark Groth16 artifacts is very slow in practice, especially on Windows.

Notes

  • Regular examples default to BN254 and BLS12-381 where the circuit supports both curves.
  • Recursion keeps the real pairings explicit: BN254 in BN254 for emulated-field education, BLS12-377 in BW6-761 for the efficient 2-chain case, and PLONK variants separately.
  • Public signals for snarkjs export come from gnark's publicWitness order rather than hand-written vectors.

About

A collection of educational examples demonstrating zero-knowledge proof implementations using the gnark library.

Topics

Resources

License

Stars

Watchers

Forks

Contributors