No description
Find a file
Bartosz Nowak dd44a6f652
docs: add project banner to README
Adds the Stwo Gnark Verifier banner image to the .github directory and embeds it at the top of the documentation.
2026-01-08 17:59:18 +01:00
.github docs: add project banner to README 2026-01-08 17:59:18 +01:00
blake2s docs: fix typo in blake2s test comments 2025-12-04 12:12:22 -03:00
channel doc/refacto: channel folder 2025-12-11 19:01:19 +01:00
circle refacto/doc: circle folder 2025-12-11 20:20:10 +01:00
components refacto/doc: variables and components folders 2025-12-12 12:58:11 +01:00
docs refacto/doc: fri folder 2025-12-12 11:56:58 +01:00
fri bug: remove witness hinting (#39) 2026-01-07 14:02:28 +01:00
m31 bug: remove witness hinting (#39) 2026-01-07 14:02:28 +01:00
test_data feat: update readme and test files (#40) 2026-01-07 14:04:45 +01:00
utils bug: register hints 2025-12-16 16:10:05 +01:00
variables bug: remove witness hinting (#39) 2026-01-07 14:02:28 +01:00
verifier bug: remove witness hinting (#39) 2026-01-07 14:02:28 +01:00
.gitignore feat: update readme and test files (#40) 2026-01-07 14:04:45 +01:00
.golangci.yml chore(lint): add golangci-lint configuration 2025-12-04 10:53:23 -03:00
go.mod feat: queries generation and verification 2025-11-25 15:41:10 +01:00
go.sum feat: added and tested blake2s compression (#2) 2025-10-06 17:36:32 +02:00
LICENSE chore: add Apache License 2.0 2026-01-07 12:09:51 +01:00
main.go bug: remove witness hinting (#39) 2026-01-07 14:02:28 +01:00
Makefile build: include tests in default target and use short mode 2025-12-04 13:38:00 -03:00
README.md docs: add project banner to README 2026-01-08 17:59:18 +01:00

Stwo Gnark Verifier

Stwo Gnark Verifier

A Go-based implementation of a Zero-Knowledge verifier for the Stwo STARK proving system, built using the Gnark SNARK library.

This project implements a SNARK circuit designed to verify Cairo STARK proofs generated by Stwo Cairo (Starknet's next-generation Circle STARK prover). By porting the Stwo Circle STARKs verifier logic into a Groth16 or Plonk circuit, it enables efficient on-chain verification of Cairo ZKVM execution traces.


🌟 About

Directly verifying Circle STARK proofs on-chain can be computationally expensive. This repository bridges that gap by providing:

  • Recursive Proofs: Wrap a high-performance Stwo STARK proof into a constant-size SNARK proof.
  • EVM Compatibility: Verify large Cairo ZKVM execution traces with minimal gas costs on Ethereum.
  • Go-Powered Verification: Leverage the speed of Go and the Gnark framework for robust verifier implementations.

🏗 Architecture

The project is structured to mirror the core components of the Stwo prover:

  • m31/: Core arithmetic for the Mersenne-31 field.
  • qm31/: Implementation of the quartic extension field used for statistical soundness and security.
  • circle/: Circle curve operations, including domain definitions, group laws, and vanishing polynomials over the circle group.
  • fri/: Implementation of the Circle FRI (Fast Reed-Solomon Interactive Oracle Proof of Proximity) protocol and high-performance Merkle verification using Blake2s.
  • components/cairo_components/: AIR constraint evaluation logic for Cairo ZKVM opcodes and built-in functions.
  • variables/: Optimized data structures for proof deserialization and Gnark circuit variables.

🛠 Usage

Prerequisites

  • Go 1.24+
  • Rust/Cargo (only for generating custom shape files)

Running the Main Verifier

The entry point main.go demonstrates the full pipeline: loading a proof, compiling the circuit, performing a setup, generating a witness, and finally producing and verifying a Groth16 proof.

go run main.go

All Components (1 Query) Fixture

This repo includes a ready-to-run fixture for development:

  • test_data/all_components_one_query.json
  • test_data/all_components_one_query_shape.json

Run the verifier test directly:

go test -v --short ./verifier

Generating Shape Files

Shape JSON files define the circuit structure. They are produced by cairo-prove in the stwo-cairo ecosystem. To generate them, you need the circuit-data-gen branches:

  1. Clone and link these repositories in the same parent directory:
  1. Navigate to stwo-cairo/cairo-prove and run:
cargo run -- circuit-data \
  --path /path/to/stwo-gnark-verifier/test_data/all_components_one_query.json \
  --queries 1

Use --queries to match the proofs stark_proof.config.fri_config.n_queries value.


🧪 Testing

The project contains extensive unit tests for individual field arithmetic, Cairo opcodes, and the end-to-end verification flow.

# Run all tests
go test ./...

# Run tests with the short flag (skips heavy setup)
go test -short ./...


🏷️ Versions

This project has been tested with:

  • stwo @ c95edc65e3af652db0eda433dfa1b92831ca2b64
  • stwo-cairo @ 5247e786a2c32299d653a5e8d1e5be65c0c219fe

⚠️ Disclaimer

This implementation is currently under active development.

  • Audit Status: This code has not yet been audited.

🔗 Relevant Projects

  • Stwo — StarkWare's Rust implementation of the Circle STARK protocol.
  • Stwo-Cairo — An adapter to compile and prove execution traces of the Cairo ZKVM using the Stwo backend.
  • Gnark — A fast ZK-SNARK library providing high-level APIs for designing arithmetic circuits in Go.