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.
Panagram integrates Solidity smart contracts, Noir circuits, and Barretenberg (UltraHonkBackend):
- Owner starts a round with a secret hashed answer.
- Players generate zero-knowledge proofs of their guess off-chain using Noir + JS scripts.
- Proofs are submitted on-chain via
makeGuess(). - The first valid proof mints 100 PAN tokens for the winner.
- The game enforces a minimum 1-hour round duration and ensures only one winner per round.
“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.”
- 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
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
- Owner creates a new round on-chain (
newRound()). - Player prepares private input (guess) and public input (address + answer hash).
- Generate proof off-chain using Noir circuit + JS script.
- Submit proof to Panagram contract (
makeGuess()). - Contract verifies proof via
s_verifier. - If valid and first correct guess, winner is minted 100 PAN tokens.
- Round ends, next round can only start after 1 hour.
- 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