Circuits and contracts for zk-hangmanV2.
An implementation of a frontend can be found here: https://github.com/prajwolrg/zk-hangmanV2-frontend
This is the implementation of the classic Hangman game with the use of smart contracts and zero knowledge proofs. It improves upon the work here.
The project has three main folders:
- circuits
- contracts
- scripts
The circuits folder contains all the circuits used in zkHangmanV2.
The contracts folder contains all the smart contracts used in zkGames. InitVerifier and GuessVerifier contracts are auto-generated.
The scripts folder contains the scripts for easy compilation of circuits and deployment of contracts.
The following graphic shows the structure of the most important zero knowledge elements of the zkHangmanV2 project. public
folder is created on compile.
├── circuits
│ ├── circomlib
│ │ ├── comparators.circom
│ │ ├── mimcsponge.circom
│ ├── guess
│ │ ├── guess.circom
│ ├── init
│ │ ├── init.circom
├── contracts
│ ├── contracts
│ │ ├── GuessVerifier.sol
│ │ ├── InitVerifier.sol
│ │ ├── zkHangman.sol
│ │ ├── zkHangmanFactory.sol
├── public
│ ├── guess_0001.zkey
│ ├── guess_verification_key.json
│ ├── guess.wasm
│ ├── init_0001.zkey
│ ├── init_verification_key.json
│ ├── init.wasm
git clone https://github.com/prajwolrg/zk-hangmanV2
yarn
To run cicuits, we'll utilize te script the scripts
folder:
source .scripts/compile_circuits.sh
//TODO: Automate this with script Update the solidity version and the contract name. InitVerifier: contract Verifier -> contract InitVerifier GuessVerifier: contract Verifier -> contract GuessVerifier Also bump the solidity versions on both contracts to ^0.8.0
Before deploying the contracts, create a .env
file and add to it:
MNEMONIC=<YOUR_MNEMONIC>
Now deploy to the appropriate network
npx hardhat run --network devnet scripts/deploy.js