Git Product home page Git Product logo

mastemind's Introduction

Mastermind - A game using Zk-SNARKs(Zokrates)

The rules of Mastermind

There are two players: the codebreaker and the codemaster.

The codemaster creates a secret four-digit sequence of coloured pegs, limited to red, blue, green, and yellow.

To win, the codebreaker must guess the secret sequence of pegs within a set number of attempts. After each guess, if the codebreaker does not yet have the correct solution, the codemaster must tell the codebreaker the following clue:

  • How many exact matches of colour and position there are โ€” these are are black pegs

  • How many pegs have matching colours, but are in the wrong position โ€” these are white pegs.

For example, if the solution is R R B Y, and the guess is Y R B G, the codemaster must provide this clue: 2 black pegs and 1 white peg.

Solution : Y R B G Guess : R R B Y

Exact matches : 0 1 1 0 -> 2 black pegs Inexact matches: 0 0 0 1 -> 1 white peg Inexact matches do not overlap; for instance:

Solution : R R Y B Guess : G G R B

Exact matches : 0 0 0 1 -> 1 black peg Inexact matches: 0 0 1 0 -> 1 white peg (not two, even though there are two red pegs in the solution) Applied to the Mastermind board game, snarks could thereby prove that a clue about a secret combination of colours is correct, without revealing the secret itself.

Implementation

In the implementation the hidden solution is an a array of 4 non-zero digits i.e ["1","2","3","4"] (say).

To reset the private solution run :

sh scripts/set_soln.sh

To play the game :

sh scripts/play.sh

It takes about 3-4 minutes to generate the proof which includes compilation of zok file,witness computation, proof generation and verifier contract generation.

Improvements

  • Reduction in proof generation time.
  • Frontend to facilitate the game play.

Requirements

  • Hardhat
  • Zokrates

Resources

mastemind's People

Contributors

garryfcr avatar man2706kum avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

man2706kum

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.