# Provably Fair

**Verification**

Magebets generates all random numbers in a way so that users can verify the validity of
each number and be sure the number was not manipulated in any way.

The explanation below might be quite difficult for most of you to understand

but this technical documentation provides a rigorous proof why there is no way

we could possibly cheat players or rig the rolls, as this is simply mathematically impossible.

Our random numbers are generated with 3 values: the server seed, the client seed and a nonce.

The server seed is generated by Magebets, the client seed is generated by the user and a nonce (the number of bets with the current seeds).

We initially give you the hash of the server seed, this means we are not able to modify the server seed later on, as this would change the hash of the server seed.

To generate a number we calculate the

If this decimal is higher than 999999, we take the next 5 characters from this string, if this happens again, we continue to take the next 5 characters.

In the unlikely event that we reach the end of the string before finding a decimal smaller or equal to 999999, your roll becomes automatically 99.99 (=win).

Once we have this number from 0 to 999999, we take the modulo 10000, this gives us a number from 0 to 9999.

We divide this number by 100, this gives us a number from 0 to 99.99.

You can use the code snippet below to verify the rolls.

The explanation below might be quite difficult for most of you to understand

but this technical documentation provides a rigorous proof why there is no way

we could possibly cheat players or rig the rolls, as this is simply mathematically impossible.

Our random numbers are generated with 3 values: the server seed, the client seed and a nonce.

The server seed is generated by Magebets, the client seed is generated by the user and a nonce (the number of bets with the current seeds).

We initially give you the hash of the server seed, this means we are not able to modify the server seed later on, as this would change the hash of the server seed.

To generate a number we calculate the

**hmac-sha512(server_seed, client_seed-nonce)**, this gives us a hex string. We take the first 5 characters from this string and convert it into a decimal. This decimal is in the range: 0-1,048,575If this decimal is higher than 999999, we take the next 5 characters from this string, if this happens again, we continue to take the next 5 characters.

In the unlikely event that we reach the end of the string before finding a decimal smaller or equal to 999999, your roll becomes automatically 99.99 (=win).

Once we have this number from 0 to 999999, we take the modulo 10000, this gives us a number from 0 to 9999.

We divide this number by 100, this gives us a number from 0 to 99.99.

You can use the code snippet below to verify the rolls.

//the seed pair itself var clientSeed = "your client seed"; //dont forget to exclude the dash and the nonce! var serverSeed = "your server seed"; //bet made with seed pair (excluding current bet) var nonce = 0; //crypto lib for hmac function var crypto = require('crypto'); var roll = function(key, text) { //create HMAC using server seed as key and client seed as message var hash = crypto.createHmac('sha512', key).update(text).digest('hex'); var index = 0; var lucky = parseInt(hash.substring(index * 5, index * 5 + 5), 16); //keep grabbing characters from the hash while greater than while (lucky >= Math.pow(10, 6)) { index++; lucky = parseInt(hash.substring(index * 5, index * 5 + 5), 16); //if we reach the end of the hash, just default to highest number if (index * 5 + 5 > 128) { lucky = 99.99; break; } } lucky %= Math.pow(10, 4); lucky /= Math.pow(10, 2); return lucky; } roll(serverSeed, clientSeed+'-'+nonce);

Copyright (c) 2017 MAGEBETS