G A M E
L O G S
Mastermind is a game of breaking codes. It involves two parties: the code maker and the code breaker.
Every game, the computer (the code maker) comes up with a random code. You're goal as the code breaker is to correctly guess the code within 10 turns.
Each time you make a guess, you can check it and the code breaker will tell you how close your guess was with two simple pieces of information:
(1) How many of the pegs in your guess are the correct color and in the correct position? - This is represented with the number of red pegs in the code breakers response
(2) How many of the pegs in your guess are the correct color but in the wrong position? - This is represented with the number of white pegs in the code breakers response
For example, we can conclude that the following guess has one peg with the correct color and position, and two with the correct color but wrong position, from the code breaker’s response on the right.
Note that the pegs in the code breaker's response aren't in any particular order corresponding with the guess.
Using only this information, you have to break the code.
You may be wondering how zero-knowledge proofs fit into all this.
Consider the following question: how do you know that the code breaker is telling the truth when it gives you its response?
Since you don't have the code, the code breaker could be completely lying about how much of your guess is correct, and you wouldn't know. So how do we solve this issue?
What if the code breaker could prove to us that they have some specific code - and for that code, our guess has a specific number correct and partially correct - all without revealing the code itself.
This is exactly what zero-knowledge proofs let us do!
In fact, this is exactly what's happening with this game:
(1) You submit your guess and the code breaker responds with the number correct and partial, along with a zkSNARK proof that they are telling the truth.
(2) You can verify this proof by sending it to a smart contract deployed on-chain, which will confirm that the zkSNARK is valid.