1

MoneroDice is a dice gambling game that uses cryptography for provably fair randomness.

How exactly does it proves its randomness?

  • It is actually answered here: monerodice.net/index.php/member/fair – uzyn Jul 20 '16 at 2:23
  • 4
    @uzyn If you have an answer, please post it below. Stack Exchange is not a search engine or a collection of links. We're here to provide definitive answers to questions about Monero, so when people come here looking for this information, please do not send them elsewhere to find that information. Thanks. – Robert Cartaino Jul 20 '16 at 13:21
  • 1
    @uzyn I've seen that, half of the page is the source code (which I don't know how it proves anything), other half (with some typos and lack of formatting) doesn't make sense for me. I'd prefer plain English please. – kenorb Jul 20 '16 at 16:13
  • @RobertCartaino Yup I am aware of that. Just not sure if we should be reproducing what's already clearly answered at the official site of MoneroDice (which is not really Monero). – uzyn Jul 21 '16 at 7:34
  • 3
    @uzyn Then why have this site at all? If this site makes it out private beta, the folks here will work hard to curate this collection of knowledge. So when someone finally finds this site through search, the last thing we should be doing is sending them elsewhere to find that information. – Robert Cartaino Jul 21 '16 at 12:44
2

A hex string is created using 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 process 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.

With the nonce you roll results can be verified with this PHP code below

  • 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

code:

if(count($argv) != 5){ print "useage: 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]);

//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, $i, 5);
    if(strlen($sub) == 5)
    {
        $decimal_number = hexdec($sub);

        if($decimal_number < 1000000)
        {
            $decimal_fourc = bcmod($decimal_number, 10000);
            $final_decimal = bcdiv($decimal_fourc, 100, 2);
            return $final_decimal;
        }
    }
    else
    {
        break;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.