This project implements a privacy-preserving, multiplayer variant of the Battleship game using zkSNARKs (Zero-Knowledge Succinct Non-interactive Arguments of Knowledge) to enforce the rules without relying on a third party, built on the RISC Zero architecture, a zero-knowledge verifiable general computing platform. The goal is to ensure that all players follow the game’s logic, such as placing valid ship configurations, reporting shot outcomes truthfully, and winning only when conditions are satisfied, while keeping sensitive information (i.e., fleet configuration) private throughout the game.
A more thorough description of the project aswell as the implementation can be found in the docs directory.
This project follows a modular structure inspired by the RISC Zero Rust Starter Template, but separates each logical component into its own crate under src/. Each subdirectory (e.g. host, blockchain, fleetcore, methods/guest) contains its own Cargo.toml and src/.
src/
├── blockchain/
├── fleetcore/
├── host/
└── methods/
├── guest/
└── src/
In a RISC Zero project, the terms methods and guest are part of the framework's architecture that enables zero-knowledge proofs of computation.
Run this once to build and launch the containers in the background:
docker-compose up --build -dNote that:
--buildforces a rebuild of the Docker image using the Dockerfile (needed only if an alteration to said file was made).-dstarts the containers in the background. If this flag is not used the terminal will display:[+] Running 2/2 ✔ Container chain0 Created 0.0s ✔ Container player0 Created 0.0s Attaching to chain0, player0
This:
- Builds the Docker image from the
Dockerfile - Starts all services defined in
docker-compose.yml(player0,chain0) - Mounts the source code directory to
/workspace
To enter the shell of a specific container:
# Enter the player container
docker exec -it player0 bash
# Enter the chain container
docker exec -it chain0 bashInside each container, use Cargo to run each program instance:
# For a player:
cd src/host/src
cargo run --bin host
# For the chain:
cd src/blockchain/src
cargo run --bin blockchainTo stop the containers, either write:
docker-compose downOr if the -d flag was not used, simply use Ctrl + c on the terminal docker-compose up was invoked