Skip to content

fahim-zk/ZK-Panagram-Solidity-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Panagram — End-to-End Zero-Knowledge Puzzle Game (Noir + Barretenberg)

This repository demonstrates a complete Zero-Knowledge Proof (ZKP) game pipeline on Ethereum.

Panagram is ZK Game where Players submit zero-knowledge proofs (ZKPs) to guess a secret answer each round. Correct guesses earn ERC20 PAN tokens, and rounds are controlled by the contract owner. The game integrates Solidity smart contracts, Noir circuits, and Aztec Barretenberg backend for ZK proof verification. Panagram allows players to solve puzzles without revealing the answer. The contract verifies each guess using zero-knowledge proofs. Players earn 100 PAN ERC20 tokens for being the first to guess correctly in each round. Each round lasts a minimum of 1 hour, and rounds can only start after the previous round has a winner.

The Summary Flow

Panagram integrates Solidity smart contracts, Noir circuits, and Barretenberg (UltraHonkBackend):

  1. Owner starts a round with a secret hashed answer.
  2. Players generate zero-knowledge proofs of their guess off-chain using Noir + JS scripts.
  3. Proofs are submitted on-chain via makeGuess().
  4. The first valid proof mints 100 PAN tokens for the winner.
  5. The game enforces a minimum 1-hour round duration and ensures only one winner per round.

What This Project Proves

“I know the correct answer to the puzzle without revealing it, and I can submit a zero-knowledge proof to the smart contract to claim my reward.”


Tooling Used

  • Solidity — Panagram ERC20 game contract
  • OpenZeppelin ERC20 & Ownable — token & access control
  • Noir — ZK circuit language and compiler
  • Barretenberg (UltraHonkBackend) — proof generation and verification backend
  • Foundry — smart contract testing & deployment
  • Node.js / TypeScript — JS proof generation script
  • ethers.js — ABI encoding and proof handling

Project Structure

panagram/
├── src/
│   └── panagram.sol          # Panagram game contract
│   └── Verifier.sol          # HonkVerifier interface / contract
├── Circuits/
│   └── main.nr               # Noir circuit
│   └── target/               # Compiled circuit and output
├── Js-scripts/
│   └── generateProof.ts      # Generates ZKP using Noir + Barretenberg
├── test/
│   └── PanagramTest.t.sol    # Foundry tests
└── README.md                 

High-Level ZK Pipeline

  1. Owner creates a new round on-chain (newRound()).
  2. Player prepares private input (guess) and public input (address + answer hash).
  3. Generate proof off-chain using Noir circuit + JS script.
  4. Submit proof to Panagram contract (makeGuess()).
  5. Contract verifies proof via s_verifier.
  6. If valid and first correct guess, winner is minted 100 PAN tokens.
  7. Round ends, next round can only start after 1 hour.

NOTE

  • DUE TO UNKOWN ERROR ENCOUNTERED ([FAIL: ProofLengthWrongWithLogN(16, 8032, 9024)]) FROM THE SMARTC CONTRACT VERIFICATION, MORE TESTS COULD NOT BE WRITTEN. FEEL FREE TO SOLVE THE PROBLEM AND TAG ME ON X

About

A solidity game logic integrated with ZK proof answers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors