What is provably fair and how does it work?

Last updated: April 6th, 2015
Verifiy Click the button to open a JSFiddle to verify your rolls

Provably fair is a way to prove that there is no way for Betcoin to manipulate the outcome of a randomly generated roll. The way this is done is through the use of cryptographic hashes in which you provide a random seed and we provide a random seed.

Here is a diagram showing how the provably fair process works:

The client (player) is auto-assigned a seed that they can use or change. The client seed can be set to anything random that they want to use. The server also creates a random seed which it keeps private. The client seed is then combined with the server seed in addition to one other constantly changing number: the total # of bets made by the player with the current seed pair. So the client seed, the server seed and the total # of bets are all combined into a hash which can be viewed before the spin takes place.

This hash can only be generated with these 3 pieces of information and this hash will always produce the same roll when ran through the publicly viewable roll algorithm. Because of this the roll can be proved with all 3 pieces of information: the client seed, the server seed and the total # of bets made with the pair.

Before any roll the player has 2 of these 3 pieces (client seed and total # of bets). The missing piece, the server seed, can be obtained by the player after every role. Once this is obtained the player can confirm that the server did indeed use this key to generate the hash.

Here is the PHP code used to generate the roll:

$client_seed = 'abc'; //user generated seed
$server_seed = 'def' //secret server seed
$total_bets = 0; //total number of bets made with this seed pair
$hash = hash_hmac('sha512', $server_seed, $client_seed . '-' . $total_bets);
$index = 0;
$start = $index * 5;
$end = 5;
$sub = substr($hash, $start, $end);
$roll = intval($sub, 16);
while($roll >= 1000000){
$index++;
$start = $index * 5;
$end = 5;
$sub = substr($hash, $start, $end);
$roll = intval($sub, 16);
if($roll >= 1000000){
if($index * 5 + 5 > 128){
$roll = 99.99;
return $roll;
}
}
else{
break;
}
}
$roll %= 10000;
$roll /= 100;
return $roll;
?>

Comments

You must be logged in to comment