Hello world,
Based on community feedback, we're currently in the process of upgrading the Crash game algorithm with salting as requested. The purpose of this post is to describe the new changes within the game result algorithm in addition to publicizing our reseeding event for Crash. Below are the differences in how the game results are generated:
OLD GAME RESULT FORMULA
const gameResult = (seed) => {
const nBits = 52; // number of most significant bits to use
// 1. r = 52 most significant bits
seed = seed.slice(0, nBits / 4);
const r = parseInt(seed, 16);
// 2. X = r / 2^52
let X = r / Math.pow(2, nBits); // uniformly distributed in [0; 1)
X = parseFloat(X.toPrecision(9));
// 3. X = 99 / (1-X)
X = 99 / (1 - X);
// 4. return max(trunc(X), 100)
const result = Math.floor(X);
return Math.max(1, result / 100);
};
NEW GAME RESULT FORMULA
const gameResult = (seed, salt) => {
const nBits = 52; // number of most significant bits to use
// 1. HMAC_SHA256(message=seed, key=salt)
const hmac = CryptoJS.HmacSHA256(CryptoJS.enc.Hex.parse(seed), salt);
seed = hmac.toString(CryptoJS.enc.Hex);
// 2. r = 52 most significant bits
seed = seed.slice(0, nBits / 4);
const r = parseInt(seed, 16);
// 3. X = r / 2^52
let X = r / Math.pow(2, nBits); // uniformly distributed in [0; 1)
X = parseFloat(X.toPrecision(9));
// 4. X = 99 / (1-X)
X = 99 / (1 - X);
// 5. return max(trunc(X), 100)
const result = Math.floor(X);
return Math.max(1, result / 100);
};
Prior to being used for calculation, each game hash is salted with the lowercase + hexadecimal string representation of the hash from pre-selected Bitcoin block 635,380. This block has not been mined yet as of this post, proving that we have not deliberately selected a mined block with a hash that could be favorable to the house. Once block 635,380 has been mined, the results will be posted to this thread as a reply. The game this post is referencing is at
https://bc.game/crash.
Hello
I don't understand it seems to be exactly the same code as the one you've posted one year ago.
So what's the difference except the block number of the salt?
This will reuse the idea posted by Ryan and used for Bustabit v2.
Starting with a secret I've generated a chain of 10,000,000 SHA256 hashes. Each element is the hash of the lowercase, hexadecimal string representation of the previous hash. The hash of the chain's last element is
f6c4a94c4a2dd2912fbef23fb68aa56488313a343c9cf6c95e52b8ef74230991 .
Every game maps to a hash in the chain: The 10,000,000th element of the chain is the hash of game #1 and the first element in the chain is the hash of game #10,000,000. To verify that a hash belongs to a game #n, simply hash it n times and compare the result with the terminating hash.
To calculate a game's result from its hash:
const crypto = require("crypto")
function gameResult(seed, salt) {
const nBits = 52 // number of most significant bits to use
// 1. HMAC_SHA256(key=salt, message=seed)
const hmac = crypto.createHmac("sha256", salt)
hmac.update(seed)
seed = hmac.digest("hex")
// 2. r = 52 most significant bits
seed = seed.slice(0, nBits/4)
const r = parseInt(seed, 16)
// 3. X = r / 2^52
let X = r / Math.pow(2, nBits) // uniformly distributed in [0; 1)
// 4. X = 99 / (1-X)
X = 99 / (1 - X)
// 5. return max(trunc(X), 100)
const result = Math.floor(X)
return Math.max(1, result / 100)
Before being used to calculate the corresponding result, each game hash is salted with the lowercase, hexadecimal string representation of the hash of bitcoin block
582,678 .
This block has not been mined yet at the time of starting the provably fair seeding event, proving that I have not deliberately picked a chain that is unfavorable for players.