This project implements a classic Subset Sum game enhanced with zk-SNARKs (Zero-Knowledge Succinct Non-Interactive Arguments of Knowledge). The game challenges players to select a subset of numbers from a given list such that their sum matches a target value. Using zk-SNARKs, players can prove their solution without revealing the actual subset.
- Secure Verification: Verify subset solutions using zk-SNARKs without revealing private inputs.
- Interactive Frontend: A web UI for player to input their data and verify solutions.
- Customizable Circuit: Built using Circom to support various list sizes and target values.
To run this project, ensure the following tools are installed:
subset-sum-zk/
├── circuits/ # Circom circuits
│ ├── sum
│ │ └── sum.circom
│ │ └── compile.sh
│ │ └── generateWitness.sh
│ │ └── executeGroth16.sh
│ │ └── input.json
├── docs/ # web frontend
├── README.md
git clone https://github.com/truthixify/subset-sum.git
cd subset-sum
Navigate to the circuits/
directory and run:
cd circuits
npm install
cd sum
Compile the circuit:
./compile.sh
Generate witness:
./generateWitness.sh
Execute Groth16:
./executeGroth16.sh
You will then copy the sum.wasm
, sum_final.zkey
and verification_key.json
into the docs folder
cd ../../docs
- Open the index.html in your browser.
- Play the game to get to solve the puzzle.
- You can also play it online here
Contributions are welcome! Feel free to submit issues or pull requests to improve this project.
This project is licensed under the MIT License. See the LICENSE file for details.