Commit-Reveal
Commit-Reveal - A seed is generated, hashed and saved to the smart contract. Game end, seed is uploaded, appended with block time + block number and a random number is generated.
Game Start
When a new game is started, a secure random seed (string of characters) is generated using, generate-password, a strong password generation tool.
The seed is saved off-chain with a relationship to the ID of the new game.
This seed is hashed into a bytes256
data type using the Web3 utility keccak256
. It's then submitted to the contract when a game starts.
Game End
The endGame
function in the smart contract accepts two parameters. The game ID and the original seed.
The seed (converted to uint256), block number, and block time are concatenated. The contract runs a "modulo" function against it with the number of tickets in the game as the denominator. (Basically, the combined seed number is divided by the number of tickets and the remainder is the random number.)
Last updated