Giter VIP home page Giter VIP logo

zk-guesser's Introduction

πŸ—ΊοΈ ZK Guesser

ZK Guesser is a decentralized geo-location guessing game built on zero-knowledge proofs. Players attempt to pinpoint a hidden location on a map, but unlike traditional GeoGuessr, their exact guesses remain hidden. Through zero-knowledge proofs, the game verifies that guesses fall within a designated proximity to the actual location.

OG Image

Players can start game choosing different regions such as:

  1. World
  2. Europe
  3. Asia
  4. Africa
  5. North America
  6. Oceania

The game contracts are deployed and verified on Scroll Sepolia Blockchain. The contracts are deployed at the following addresses:

# GameLib(Helper Library for the Game)
0x3b9A09147840FeC2B40234ca717C8DEEa13985Ba
# UltraVerifier(Compiled plonk_vk prover)
0xe86b1899376c77e1a109eA2124E462EF58E56897
# ZKGuesser(Main Game Contract)
0xb2af159c02b708f3270929d6d2b0e01b415cbfab

Screenshots πŸ“Έ


Homepage

Game mode selection

Guesser Interface

SCR-20231208-cyyh

How Proofs are generated?

The Proofs are written in Noir DSL and compiled using the Noir compiler. The compiled proof is then used to verify the guess of the player. The proof is generated using the following steps:

The circuit takes the following public inputs:

  • The Game Operator Address
  • The Hashed message to be signed by operator
  • Range Start
  • Range End
// Hashed Message
keccak256(abi.encodePacked(playerAddress, gameId, currentRound, start, end));

And the following private inputs:

  • The player's guess
  • The Actual Answer
  • Operator's Signature for the hashed Message
  • Operator Public Key X
  • Operator Public Key Y
  1. First the Signature is Verified using the Operator's Public Key and the Hashed Message.
  2. Then the guess is verified to be within the range of the actual answer.
  3. The proof is then generated using the above inputs and the compiled proof is then used to verify the guess of the player.

The Circuits also use an Oracle to calculate distance between the co-ordinates of the guess and the actual answer. The Oracle is a simple RPC server that calculates the distance between two co-ordinates.

An example can be found in the packages/rpc-server directory.


How Random Locations are Generated?

Random locations around the globe or a region are done using geo spatial data. Under the hood it uses libraries like @turf/bbox-polygon and @turf/area to compute on the existing Geo Spatial data and generate coordinates avoiding water bodies and other non-land areas.


πŸ§‘πŸΌβ€πŸ’» Tech Stack

  • Frontend: Next.js, Tailwind CSS, shadcn
  • Integration: wagmi, viem, noir-js
  • Smart Contracts: Foundry, Solidity, Scroll Sepolia
  • Circuits: Noir DSL, Noir Compiler
  • Map Components: Mapillary, Leaflet

πŸš€ Quick Start

Clone the repository

git clone https://github.com/Envoy-VC/zk-guesser.git

Install dependencies

cd zk-guesser
pnpm install

To Start Generating Proofs you need to start a small RPC server for oracles. Go to packages/rpc-server and run the following commands:

cd packages/rpc-server
pnpm dev

Then to verify the proofs, Go to packages/circuits and run the following commands:

pnpm prove

Or to test the circuit, run the following command:

pnpm test

To start the frontend, Go to apps/www and run the following commands:

cd apps/www
pnpm dev

zk-guesser's People

Contributors

envoy-vc avatar turbobot-temp avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.