Provably Fair

What is provable fairness

Provable fairness is a transparent way for us to guarantee that we are providing true randomness without manipulation - and that you, as a player can verify mathematically that this is true.

To ensure operating honestly, the provably fair algorithm is implemented to provide a completely transparent and verifiable solution of bet outcomes. This in short means that you have a complete power over your gambling experience, and can be assured there is true randomness when you play our games.

Every game on dice .church uses the same algorithm to generate verifiable random numbers.

Implementation

For each verifiable bet, 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 function. This function creates 32 random bytes (0-255) from a given server seed and a message. 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 function are used. The message is then created by concatenating the client seed, a colon, the nonce, another colon and the incremental number.

For example, for client seed 'test1234', nonce: 'nonce' and a first round, message will be 'test1234:nonce:0'

Client Seed

This is a random text that you can put (or leave it blank). This can be edited and changed regularly (if desired) to create a new chain of randomness. Because you decide when to and how to change your seed, we cannot manipulate server seed in any way to generate numbers we want - as you can change your client seed at will.

Server Seed

The server seed is generated by our system as a random 64-character hex string. You will then be provided with an encrypted hash of the server seed before you place any bets. The seed is encrypted to ensure that the outcome cannot be calculated by the player beforehand, but still provide the guarantee that the outcome has been pre-determined and not changed after the bet has been made.

To reveal the hashed server seed, the seed must be rotated by the player,which triggers the replacement with a newly generated seed. From this point you are able to verify any bets made with the previous server seed to verify both the legitimacy of the server seed with the encrypted hash that was provided, but also with the outcomes of each bet placed on the casino when it was active.

Nonce

The nonce is simply a number that increments as every new bet is made. This generates a unique input per game, without having to generate a new client seed and server seed each time you play.

How to Verify

To verify, first you need to change your server seed in profile options to reveal previous one. Then, you can verify that seed hash you previously owned is actually a hash of a server seed we showed you - to do this, get a server seed of a game round and hash it through SHA256 - you have to remember that given Server Seed is in hex format, so you need a converter that can interpret given number as binary hash, i.e. you can use https://www.fileformat.info/tool/hash.htm - use 'binary hash' option. For example. if your server seed is '4babe5690cb4bba57a45267a7b0234ebfacb80ac231df6a9338c7d9cbf38e5b3', you should put it into binary hash field and your sha-256 hash should be equal to 'c153b4d6a284002dbbea66dbd36303997e5d02fd95b2913df944c09751d6f97a' - this way you can verify that hash you owned was actually a hash of this given Server seed.

Second step is to generate result using HMAC SHA-256. You can do this using an online tool like https://codebeautify.org/hmac-generator - similarily to last step, you can use any tool you like, as long as it interprets secret key as a hex string.
To verify result, you need to provide Server Seed as a secret key (sometimes called just a key) and message to hash is a message for your bet, created as described above.
Let's say your Server Seed is '4babe5690cb4bba57a45267a7b0234ebfacb80ac231df6a9338c7d9cbf38e5b3', you had no Client Seed, nonce is 57 and we are calculating for 1st round (round 0). Your message would be ':57:0', you would hash it using key '4babe...', as a result you will receive a value 'e5593cf24c1ed1ba39c152738e74a67ee80a6c9829e3b0d68b9a51d2e87c3b36'.
Now - how can you decipher what result you received? That depends on game, below there are all games described, let's say you are playing dice - as described, 4 bytes are used to create a float number and that it is multiplied by 10001.
So, let's do those calculation on our example, our first 4 bytes equal to:
'e5', '59', '3c', 'f2' - in decimals it would be 229, 89, 60, 242.
Next, let's calculate a float value in range [0 ... 1):

229 / (256 ^ 1) + 89 / (256 ^ 2) + 60 / (256 ^ 3) + 242 / (256 ^ 4)
- which equals 0.895893. If we multiply this number by 10001 - 0.895893 * 10001 = 8959.825 and get only integer part (8959) we will receive our final answer, which is 8959. And in fact, this is exactly what you would receive if you would play dice with those seeds as in example. You can of course verify your bets using similar formulas, there are also more calculators online which helps you verify them quicker then by hand - we wanted to give you full look into the mathematics of how our random number generator works, so that you can use any tool you like for your own needs.

Games

Dice

For dice game 1 round is generated and a number between [0, ..., 10000] is created by multiplying a random float with four bytes times 10001.