Skip to content

truthixify/subset-sum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Subset Sum zk-SNARK Game

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.

Features

  • 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.

Prerequisites

To run this project, ensure the following tools are installed:

  1. Node.js
  2. Circom
  3. SnarkJS
  4. Basic knowledge of cryptography and zk-SNARKs.

Project Structure

subset-sum-zk/
├── circuits/             # Circom circuits
│   ├── sum
│   │    └── sum.circom
│   │    └── compile.sh
│   │    └── generateWitness.sh
│   │    └── executeGroth16.sh 
│   │    └── input.json 
├── docs/             # web frontend
├── README.md

Setup and Installation

1. Clone the Repository

git clone https://github.com/truthixify/subset-sum.git
cd subset-sum

2. Install Dependencies

3. Compile the Circuit

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

Frontend:

cd ../../docs

Usage

  1. Open the index.html in your browser.
  2. Play the game to get to solve the puzzle.
  3. You can also play it online here

Contributing

Contributions are welcome! Feel free to submit issues or pull requests to improve this project.


License

This project is licensed under the MIT License. See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published