project screenshot 1
project screenshot 2
project screenshot 3
project screenshot 4
project screenshot 5
project screenshot 6

ZKGambit

Building a Zk guessing game . It uses zk-SNARK and pyth on chain oracle.

ZKGambit

Created At

Superhack 2024

Project Description

This is a gambling game that utilizes zero-knowledge proof systems, specifically zk-SNARKs, to ensure the integrity and fairness of the game. The project combines blockchain technology, cryptographic proofs, and on-chain data to create a secure and verifiable gambling experience.

Key Components: Zero-Knowledge Proofs (zk-SNARKs): Used to generate proofs and verify the game's integrity Ensures that the game's outcome can be verified without revealing sensitive information Implemented using the Bellman library in Rust

Pyth On-chain Oracle: Used to fetch on-chain data This data is used in mathematical computations to generate a random secret number Ensures randomness and unpredictability in the game

Thirdweb: Implements a wallet connection feature Allows users to log in and interact with the game using their blockchain wallets

Rust Programming Language: The primary language used to develop the project Known for its performance and safety features

Game Flow: Login Page: Users connect their wallet using Thirdweb Game Entry: System prompts the user to input a guess number Secret Number Generation: Pyth Oracle fetches on-chain data Mathematical computations are performed on this data to generate a random secret number

Zero-Knowledge Proof Generation:zk-SNARK system generates a proof using the secret number and the user's guess Verification:The zkp.rs module verifies if the guess matches the secret number without revealing either value Integrity Check:The zk system allows users to verify the integrity of the game

Technologies Used: Rust: Primary programming language Thirdweb: Wallet connection and user authentication Pyth On-chain Oracle: Fetching on-chain data for randomness Bellman library: Implementation of zk-SNARKs Zero-Knowledge Proofs: Ensuring game fairness and integrity

Security Considerations: Timing Attacks: Ensure that the time taken to generate and verify proofs doesn't leak information about the secret number. Front-running: If bets are placed on-chain, measures should be taken to prevent miners from exploiting advance knowledge of transactions. Oracle Security: The system should be resilient to temporary Pyth oracle outages or manipulated data.

This project demonstrates an innovative approach to online gambling by leveraging blockchain technology and advanced cryptographic techniques. It aims to provide a transparent, fair, and verifiable gaming experience while maintaining the necessary level of privacy and security.

How it's Made

This is a gambling game which uses zero knowledge proof system (zk-SNARK) to generate the proof and to verify the game, zk-SNARK is also used to verify the integrity of the game. I also use the Pyth On-chain Oracle to take a number from on-chain and after that doing some mathematical computations to generate a random number (which is our secret number).

To make this project: I used rust programming language, Thirdweb (for adding a connect button in the game, to connect the wallet), Pyth On-chain Oracle (to take on-chain data which is used in generating a random number) Used Bellman library for zk-SNARK

This whole system is totally interconnected Login page at the start (uses thirdweb oracle), then we enter into the game and system ask us to get a number , then system uses on-chain data which is extracted by pyth oracle to generate a random secret number, then zk system generates a proof from that secret number and guess number, the zkp.rs verifies the game that both numbers are equal or not, the zk system asks you to verify the integrity of the game This how the whole game is linked with each other.

I used "Thirdweb" and "Pyth Oracle" thirdweb helped me to create a connect wallet page and on pyth oracle my whole project is built (to generate a random secret number in different ways).

I used Zero Knowledge Proof in my system

background image mobile

Join the mailing list

Get the latest news and updates