This example is an on-chain ZK panagram game that uses Noir for the ZK circuits and Foundry for the smart contracts
git clone https://github.com/Cyfrin/zk-panagram-cu.git
npm install && cd contracts && forge install
forge test
This step is needed if you modify the circuit logic at all.
- Navigate inside the circuits folder and compile the circuit
nargo compile
- Generate the verifiaction key
bb write_vk --oracle_hash keccak -b ./target/circuits.json -o ./target
- Generate the verifier
bb write_solidity_verifier -k ./target/vk -o ./target/Verifier.sol
- Delete your old
Verifier.sol
from insidecontracts/src
and replay with the new one!
cd contracts && forge create src/Verifier.sol:UltraHonkVerifier --account <your-account> --rpc-url <your-rpc-url> --broadcast
forge create src/Panagram.sol:Panagram.sol --account <your-account> --rpc-url <your-rpc-url> --broadcast --constructor-args <your-verifier-address>
Then, add the address in constants.ts
Replace "triangles"
with your desired word:
chisel
bytes32(uint256(keccak256("trianges")) % 21888242871839275222246405745257275088548364400416034343698204186575808495617)
Take the output and add as the input to this function call:
cast send <your-panagram-address> "newRound(bytes32)" <chisel-output>
Add the scrambled answer and answer hash (the chisel output) to constants.ts
npx run dev