Mastermind Game on Agoric #10013
Jorge-Lopes
started this conversation in
Show and tell
Replies: 1 comment
-
@Jovonni suggests maybe Pedersen Commitments... or zk circuits using something like 01js. It would likely add an off-chain component for the prover. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Context
The purpose of this discussion is to showcase a simple dApp I have built to explore the gaming use case on the Agoric chain and improve my frontend skills.
Note: the release of the UI Tutorial was the trigger that motivated me to build the UI for this dApp.
GitHub Repository: https://github.com/Jorge-Lopes/mastermind
Project Overview
This dApp implements a version of the Mastermind game, where the contract will act as the code maker, which will generate a sequence of four colored pegs from a set of 6 available colors. The sequence (secret code) is kept hidden from the user until it wins or loses the game.
The user, code breaker, is allowed to make a guess of four colored pegs in a specific order and will receive a feedback in return.
The game is finished when the codebreaker guesses the exact sequence, or if it cannot guess the code within the given 10 attempts.
Key Features:
Challenges
Could a game like this be monetised?
The secret code of each new game is generated via the Mersenne-Twister package, which is a pseudorandom number generator.
At the generateSecretCode function, every time a new game is initiated, a new instance of the Mersenne Twister generator is created and used to generate a 4-digit array, using the random method to produce a number between 0 and 5.
To create the Mersenne Twister generator, we need to pass an integer (seed) into the constructor, which will always produce the same random sequence.
In this implementation, the seed being used is the absValue returned by the
getCurrentTimestamp
method of thechainTimerService
, at the moment themakeGameHandle
is executed.I am questioning if a player with access to the chain logs, (e.g. by running a node) would be able to deduce the timestamp used as seed and this way predict its secretCode?
Chain logs example:
Proposed solution
While discussing this subject during office hours with @dckc , one possible solution that was raised is to take advantage of the Agoric Orchestration pkg to interact with some Cosmos chains that provide reliable randomness, for example Nois.
To be detailed …
Hope you have found this project interesting, I'm open to any feedback or suggestions you might have on this topic.
Thank you all for your time.
Beta Was this translation helpful? Give feedback.
All reactions