Skip to content

ayushn2/zk_panagram

Repository files navigation

ZK Panagram — ERC-1155 Proof-Gated Puzzle Game

Zero-knowledge puzzle solving using Noir, Barretenberg, and an on-chain Solidity verifier.


Overview

ZK Panagram is a privacy-preserving puzzle game where users prove they solved a Panagram without revealing the solution.
A Noir circuit validates correctness, generates a SNARK proof, and a Solidity contract verifies this proof on-chain.
If verification succeeds, the user mints an ERC-1155 reward token.

This project demonstrates the complete ZK workflow:

  • Noir circuit design for puzzle validation
  • Proof + key generation using Barretenberg
  • Auto-generated Solidity verifier
  • ERC-1155 minting gated by valid ZK proofs
  • Full Foundry-based test suite

Architecture

1. Noir Circuit (circuits/panagram)

Implements puzzle validation:

  • Inputs: user’s guessed letters
  • Constraint: guess must match the correct puzzle solution
  • Output: a SNARK proof that the solver knows the correct answer without revealing it

Circuit produces:

  • Proving and verification keys
  • Proof artifacts
  • Solidity verifier source file

2. Barretenberg (bb)

Used to compile circuits, produce keys, and generate proofs.

Key commands:

nargo compile
bb prove
bb write_vk
bb write_solidity_verifier

3. Solidity Verifier + ERC-1155 Token

  • Solidity verifier contract is generated directly from the Noir/Barretenberg circuit outputs.
  • PanagramToken.sol implements ERC-1155 minting, restricted to users who provide a valid SNARK proof.

Flow:

  1. User solves the puzzle locally.
  2. Noir + Barretenberg generate a zero-knowledge proof.
  3. User submits the proof to the smart contract.
  4. Contract verifies the proof on-chain.
  5. If valid → ERC-1155 token is minted to the caller.

4. Foundry Test Suite

The test suite validates the entire pipeline:

  • Proof verification on-chain
  • Correct ERC-1155 minting
  • Rejection of invalid/malformed proofs
  • Enforcing that each wallet can mint only once

Run tests:

forge test -vvvv

How to Run

Install Noir + Barretenberg

Ensure both tools are installed and accessible:

nargo --version
bb --version

Compile the Circuit

Compile the Noir circuit:

cd circuits/panagram
nargo compile

Generate the Proof

Create the SNARK proof and output artifacts:

bb prove

Export the Solidity Verifier

Generate the on-chain verifier contract:

bb write_solidity_verifier

Move the generated Solidity file into the contracts/ directory.

Run Foundry Tests

Execute the end-to-end test suite:

forge test -vvvv

Project Structure

zk_panagram/
│── circuits/
│   └── panagram/
│       ├── main.nr
│       ├── Prover.toml
│       ├── Verifier.toml
│       └── outputs/
│
│── contracts/
│   ├── PanagramVerifier.sol
│   └── PanagramToken.sol
│
│── script/
│── test/
│── README.md

Key Learning Outcomes

  • Writing and compiling Noir circuits
  • Generating SNARK proofs with Barretenberg
  • On-chain verification using auto-generated Solidity contracts
  • ERC-1155 minting secured through zero-knowledge proofs

About

A Noir-based zero-knowledge project enabling users to prove knowledge of a solution without revealing it.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors