To create hex string we use a hash_hmac(serverSeed, clientSeed_nonce) function, where "clientSeed_nonce" is literally the client seed, the underscore character, and the nonce, all concatenated together.

Then five characters are taken from the hex string to create a roll number.

If the roll number is over 999 999 the proccess is repeated with the next five characters.

The resulting number (0 to 999 999) has a modulus of 10^4 applied to obtain a roll number (0 to 9999), and then divided by 10^2 to get a final result (0 to 99.99).

The nonce is the sum of bets you made with the current server and client seed.

To make it easier for you to verify your roll results we offer you the script below.

Simply run it on commandline on Unix-like systems which have PHP CLI installed.

More scripts for different languages will follow.

Also you can find the script on github: MoneroVerifier


#!/usr/bin/php
<?php
/*
 * Verify the roll results of Monerodice.net
 *
 * required inputs:
 * serverHash = $argv[1]
 * serverSeed = $argv[2]
 * userSeed = $argv[3]
 * nonce = $argv[4]
 *
 * outputs:
 * server hash correctness
 * roll result
*/

if(count($argv) != 5){
    print 
"usage: php verifyMonerodice.php serverHash serverSeed userSeed nonce \n";
    exit;
}



if(
hash('sha256'$argv[2]) == $argv[1]){  //check if hashed serverSeed matches serverHash
    
print "Server Hash is correct! \n";
}else{
    print 
"Server Hash is incorrect! \n";
}

//simulate dice roll to get the exact roll result
print "Roll result is: " rollDice($argv[2], $argv[3].'_'.$argv[4]) . PHP_EOL;

//function which executes dice roll based on your input
function rollDice($server_seed$secret)
{
    
$hash hash_hmac('sha512'$server_seed$secret);

    for(
$i 0$i strlen($hash); $i += 5)
    {
        
$sub substr($hash$i5);
        if(
strlen($sub) == 5)
        {
            
$decimal_number hexdec($sub);

            if(
$decimal_number 1000000)
            {
                
$decimal_fourc bcmod($decimal_number10000);
                
$final_decimal bcdiv($decimal_fourc1002);
                return 
$final_decimal;
            }
        }
        else
        {
            break;
        }
    }
}


?>

#!/usr/bin/python

'''
Verify the roll results of Monerodice.net

required inputs:
serverHash = sys.argv[1]
serverSeed = sys.argv[2]
userSeed = sys.argv[3]
nonce = sys.argv[4]

outputs:
server hash correctness
roll result
'''

import hashlib
import hmac
import sys

#function which executes dice roll based on your input
def rollDice(server_seed, secret):
    hash_result = hmac.new(secret, server_seed, hashlib.sha512).hexdigest()
    for i in xrange(0, len(hash_result)):
        sub = hash_result[i:5]
        if len(sub) == 5:
            decimal_number = int('0x'+sub, 0)

            if decimal_number < 1000000:
                decimal_fourc = decimal_number % 10000
                final_decimal = decimal_fourc / 100.0
                return final_decimal
        else:
            break
        i += 5


if len(sys.argv) != 5:
    print "usage: python verifyMonerodice.py serverHash serverSeed userSeed nonce"
    sys.exit(0)

if hashlib.sha256(sys.argv[2]).hexdigest() == sys.argv[1]:  #check if hashed serverSeed matches serverHash
    print "Server Hash is correct!"
else:
    print "Server Hash is incorrect!"

#simulate dice roll to get the exact roll result
print "Roll result is:", rollDice(sys.argv[2], sys.argv[3] + '_' + sys.argv[4])