Jump to content

Multiplayer Keno seed event - BC.Game


Coco_o

Recommended Posts

  • Admin

Dear community members,

After launching our new Multiplayer Keno game, we found that the current algorithm had a problem. Specifically, the ball shuffling gave the balls numbered 1-10 a probability of being the game's result over the other balls by 1%-2%.

Reasons:
1. The initialization order of the balls is arranged in the order of 1-40.
2. The hash used for the two ball shuffling events is the same, resulting in the similar order of the balls in the two shuffling events and the order of the balls not scattered widely enough.

1% House Edge does not affect fairness, but in order to make the game result distribution more random, we will upgrade the algorithm and choose a new salt.

Upgrading methods:
1. Adjust the initialization order of the balls. We will provide the order before the games so as to adhere to fairness standards.
2. Use a new hash for the second shuffling. The new hash will be generated through calculating the seed of the first ball shuffling with hash256 (seed).
This is the new code:

const CryptoJS = require("crypto-js");

function seedGenerator(hash, salt) {
    const hmac = CryptoJS.HmacSHA256(CryptoJS.enc.Hex.parse(hash), salt);
    return hmac.toString(CryptoJS.enc.Hex);
}
function createNums(allNums, hash) {
    const nums = [];
    let h = CryptoJS.SHA256(hash).toString(CryptoJS.enc.Hex);
    allNums.forEach((c) => {
        nums.push({ num: c, hash: h });
        h = h.substring(1) + h.charAt(0);
    });
    nums.sort(function (o1, o2) {
        if (o1.hash < o2.hash) {
            return -1;
        } else if (o1.hash === o2.hash) {
            return 0;
        } else {
            return 1;
        }
    });
    return nums;
}
function keno(hash) {
    const salt = 'salt waiting to be generated';
    const allNums = [1, 30, 11, 40, 2, 29, 12, 39, 3, 28, 13, 38, 4, 27, 14, 37, 5, 26, 15, 36, 6, 25, 16, 35, 7, 24, 17, 34, 8, 23, 18, 33, 9, 22, 19, 32, 10, 21, 20, 31];
    let seed = seedGenerator(hash, salt);
    let finalNums = createNums(allNums, seed);
    seed = String(CryptoJS.SHA256(seed));
    finalNums = createNums(finalNums, seed);
    return finalNums.slice(0, 10).map(m => m.num)
}

let hash = 'game hash';
console.log('result =>', keno( hash ).map(item => item.num).join(','));

 

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 635,810
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. Also this block has not been pre-mined which can be verified using any block explorer.

Link to comment
Share on other sites

  • Admin

Block 635,810 is mined
https://btc.com/000000000000000000076973be291d219d283d4af9135601ff37df46491cca7e
So our salt will be
000000000000000000076973be291d219d283d4af9135601ff37df46491cca7e
We will use the new algorithm after the Bet #35489 in Keno

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...