CryptoFairPlay random number generator creates provable fair random numbers that are used to determine the outcome of every game played on the site. The user is able to verify the outcome of every game in a fully deterministic way to ensure that CryptoFairPlay has not chosen random numbers in favour of the Casino. By providing one parameter, the client seed to the inputs of the random number generator, CryptoFairPlay is unable to manipulate the outcome in favour of the Casino.
The CryptoFairPlay random number generator allows each game to request any amount of random numbers from a given client seed , server seed and a nonce. Every game on CryptoFairPlay uses this list of random numbers to determine its outcome by converting them into:
- - Cards
- - Diamonds
- - Numbers
Each user has one active client seed, one active server seed and a nonce incrementing every game by 1.
Client Seed is a string or a randomly generated selection of text that is determined by the player or their browser. This can be edited and changed regularly (if desired) to create a new chain of randomness.
The server seed is generated by the server and is a random generated 64 character hex (0-9,a-f) string. CryptoFairPlay publishes the sha256 (wikipedia) hash of the server seed for the active server seed. The user can rotate the current server seed, this generates a new random active server seed and resets the nonce to 0. The previous server seed, now inactive, is then revealed and can be verified using the sha256 that was published while the seed was active.
The nonce is a number that increments by one every time a game is played. This generates a unique input per game, but keeps verifying multiple games simple, since the nonce is the only parameter that changes.
Inputs to Bytes
A client seed, a server seed and a nonce are used as the input parameters for the random number generator. Bytes are generated using the HMAC_SHA256(K,m) function (wikipedia). This function creates 32 random bytes (0-255) from a given server seed (K) and a message (m). The message is created using the client seed, the nonce and an incremental number (round). This number starting with 0 gets increased by one every time the 32 bytes returned by the HMAC_SHA256(K,m) function are used. The message is then created by concatenating the client seed, a colon, the nonce, another colon and the incremental number.
Creating game events
The output of the random number generator is a list of bytes (0, 255) that needs to be converted into random events that happen during the game like taking another card in Blackjack. This describes how random bytes are used to create game events on CryptoFairPlay.
All games require a number for a game event. In a deck of 52 cards a random card can be created removing a random number of cards between [0, 1, …, 51] from the deck and taking the next card as the random result. Other games like Roulette only require a number or use numbers for shuffling a List. By multiplying a float [0, …, 1) with a maximum value, any range of numbers can be derived from it. To create a float we take four bytes and divide its value by the maximum value relative to its position. The first byte gets divided by 256, the second byte by 65,536 (256 * 256) and so forth. The sum of the divisions per byte is an equally distributed value greater or equal than zero, but smaller than one. Taking only the full number part (floor) of the result of multiplying the floor by a maximum value, an evenly distributed full number in a range between [0, max-value - 1] is created.
A number between [0, …, 51] is chosen by creating a float using two bytes and then multiplying it with 52. Then the card is chosen by taking the nth. Card from the following Cards:
♦2, ♥2, ♠2, ♣2, ♦3, ♥3, ♠3, ♣3, ♦4, ♥4, ♠4, ♣4, ♦5, ♥5, ♠5, ♣5, ♦6, ♥6, ♠6, ♣6, ♦7, ♥7, ♠7, ♣7, ♦8, ♥8, ♠8, ♣8, ♦9, ♥9, ♠9, ♣9, ♦10, ♥10, ♠10, ♣10, ♦J, ♥J, ♠J, ♣J, ♦Q, ♥Q, ♠Q, ♣Q, ♦K, ♥K, ♠K, ♣K, ♦A, ♥A, ♠A, ♣A
Similar to Cards a Color is chosen from the following list using a value between [0, …, 6]:
green, purple, yellow, red, cyan, orange, blue
A number between [0, …, 10000] is created by multiplying a random float with four bytes times 10001. The full number [0, …, 10000] is then divided by 100.
A number between [0, …, 36] is created by multiplying a random float with four bytes times 37.
For Keno (40 fields) a range with all possible elements [0, …, 39] in the game is generated. Then the required amount of elements is picked from that list by using its position.