I'm trying to verify dice rolls but getting wrong roll numbers generated. I've tried official verification script from 2 sites:
- primedice.com nodeJS verification script.
- bitsler.com and PHP script to check a roll.
Can you help me understanding why I can't get the same roll numbers as on sites...Let's focus on primedice, because I think the issue is surely similar.
details of a primedice.com roll:
roll #20,549,462,672
server seed (hashed) : a72c7d6e95b7122dc21968505b91d729f4eef30af2c019488bb76274290ad183
client seed (nonced) : a9e65af098fe00229917de5659746dda-28
roll number shown on site: 35.02
I suppose the nonce to use there is 28 in the code. so I fill nodejs variable as this:
var clientSeed = "a9e65af098fe00229917de5659746dda";
var serverSeed =
"a72c7d6e95b7122dc21968505b91d729f4eef30af2c019488bb76274290ad183";
var nonce = 28;
//----- official roll function from primedice.com
var crypto = require('crypto');
var roll = function(key, text) {
var hash = crypto.createHmac('sha512', key).update(text).digest('hex');
var index = 0;
var lucky = parseInt(hash.substring(index * 5, index * 5 + 5), 16);
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;
}
console.log(roll(serverSeed, clientSeed+'-'+nonce));
then used the roll function as given by the site. the result generated was:
roll number generated : 50.64
so 50.64 is not what the site shows ==> 35.02
Any idea?