Today, I'm thrilled to launch isitprovablyfair.org, a brand new site that will allow players to verify in just a few seconds if the game they just played on Bustabit was provably fair.
It does this by checking if the game hash inputted by the user is on the same hash chain as the terminating hash that was generated in the 2018 seeding event: https://bitcointalk.org/index.php?topic=2807542.0. It can go through millions of games in just a matter of seconds.
How do we do that exactly ? We hash the game hash n times (n being the game ID), and then we check to see if the result matches with the terminating hash. If the result matches with the terminating hash, the game is provably fair. If it doesn't, then the game was altered.
Here is the NodeJs code used to check for the terminating hash:
Code:
function verifyingGameHash(data, gameID) {
let hashedSeed = data;
for (let i = 0; i < gameID; i++) {
hashedSeed = crypto.createHash('sha256').update(hashedSeed).digest('hex');
}
return hashedSeed;
}
And finally, we also calculate the game bust with the salted hash of Bitcoin block #505750 to ensure that it matches too.
Code:
const gameResult = (seed, salt) => {
const nBits = 52;
const hmac = crypto.createHmac('sha256', salt);
hmac.update(Buffer.from(seed, 'hex'));
seed = hmac.digest('hex');
seed = seed.slice(0, nBits / 4);
const r = parseInt(seed, 16);
let X = r / Math.pow(2, nBits);
X = 99 / (1 - X);
const result = Math.floor(X);
return Math.max(1, result / 100);
};
const sha256 = (str) => {
return crypto.createHash('sha256').update(str).digest('hex');
};
const gameBust = (gameHash, numRounds) => {
let prevHash = null;
for (let i = 0; i < numRounds; i++) {
let hash = prevHash ? sha256(String(prevHash)) : gameHash;
let bust = gameResult(hash, '0000000000000000004d6ec16dafe9d8370958664c1dc422f452892264c59526');
return bust
prevHash = hash;
}
};
All the code for this website is open source and available on Github: https://github.com/drkhero/isitprovablyfair
If this website gains traction and if there's interest for it, I'll be extending support for other casinos too. Do not hesitate to give feedback and let me know what you all think!