Coder Social home page Coder Social logo

zk-mastermind-circom's Introduction

zk-mastermind-circom

Mastermind Game Verifier in Circom.

Overview

This Circom program implements a zero-knowledge proof (ZKP) for verifying a solution to the Mastermind game without revealing the solution itself. The program uses cryptographic hashing and zk-SNARKs to prove that the player has correctly guessed the number of exact and near matches (black and white pegs) of a hidden solution.

Prerequisites

  • Circom 2.0.0 or higher

Files and Directories

  • mastermind_sha256.circom: Contains the SHA-256 hashing logic for the solution.
  • comparators.circom: Imported from circomlib, used for equality and greater-than checks.
  • bitify.circom: Imported from circomlib, used for bit-level operations.

Inputs and Outputs

Public Inputs

  • pubGuessA, pubGuessB, pubGuessC, pubGuessD: The player's guesses for the puzzle.
  • pubNumBlacks: The number of exact matches (black pegs) claimed by the prover.
  • pubNumWhites: The number of near matches (white pegs) claimed by the prover.
  • pubSolnHash: The hash of the solution, used for verification.

Private Inputs

  • privSolnA, privSolnB, privSolnC, privSolnD: The actual solution to the puzzle (hidden).
  • privSalt: A salt used in hashing the solution for additional security.

Outputs

  • solnHashOut: The computed hash of the solution, compared against pubSolnHash for verification.

Functionality

Counting Black Pegs

The program compares each guess element with the corresponding solution element. If they match, the black peg count (nb) is incremented.

Counting White Pegs

  • The program checks for matching elements between guesses and solution, excluding already matched pairs.
  • For each potential match (excluding exact matches), if a guess element matches any solution element, the white peg count (nw) is incremented.

ZK Proof

  • The program ensures the counts of black and white pegs (pubNumBlacks and pubNumWhites) match the computed values (nb and nw).
  • It uses SHA-256 hashing (via mastermind_sha256.circom) to verify the solution against the public solution hash (pubSolnHash).

Appendix: Dapp repositories

The relevant repositories of the mastermind Dapp are as follows:

  1. zk-mastermind-webdapp: Frontend application of the Mastermind Dapp.
  2. zk-mastermind-backend: Backend application of the Mastermind Dapp.
  3. zk-mastermind-backend-onchain: Hada mint contrat of the Mastermind Dapp.
  4. zk-mastermind-docker: Docker container with the Kupo, Hydra and Cardano node components of the Dapp.
  5. zk-mastermind-circom: Circom circuits of the mastermind Dapp.
  6. zk-mastermind-plutus: PlutusTx validator that implements the logic of the game.
  7. zk-mastermind-aiken: Aiken validator that implements the logic of the game.

zk-mastermind-circom's People

Contributors

jmagan avatar agustinbadi avatar ajuggler 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.