FloatingLamps

ETCBets.com - Providing Provably Fair iGaming for Ethereum Classic | Dice | Parabolic

10 posts in this topic

1) We have generated a chain of 10 million sha256 hashes, starting with a server secret that has been repeatedly fed the output of sha256 back into itself 10 million times. The sha256 of the final hash in the chain is: c56c9fe892bd23ff6d20da0b505c86db9acecb6a257a2b79b23dfface1d4ea75, by publicising it here we are preventing any ability to pick an alternate sha256 chain.

 

 

2) Parabolic will play through that chain of hashes, in reverse order, and use the hashes to determine the crash point in a probably fair manner.

 

3) To avoid criticism that the Bitcoin address used in step 1 was carefully chosen to generate lots of "bad" crash points, each hash in the chain will be salted with a client seed, which we have no control of. The client seed will be the block hash of a Bitcoin block that hasn't yet been mined: block 465525.

 

 

The reference code (javascript) is as follows:

 

The method to create the hash chain is simply sha256:


function genGameHash(serverSeed) {
  return crypto.createHash('sha256').update(serverSeed).digest('hex');
}

 

The method to convert a game hash, mix it with the picked client seed to a game multiplier:

 


function crashPointFromHash(serverSeed, clientSeed) {
  function divisible(hash, mod) {
    // We will read in 4 hex at a time, but the first chunk might be a bit smaller
    // So ABCDEFGHIJ should be chunked like  AB CDEF GHIJ
    var val = 0;
    
    var o = hash.length % 4; 
    for (var i = o > 0 ? o - 4 : 0; i < hash.length; i += 4) {
      val = ((val << 16) + parseInt(hash.substring(i, i+4), 16)) % mod;
    }
 
    return val === 0;
  }
 
  var hash = crypto.createHmac('sha256', serverSeed).update(clientSeed).digest('hex');
 
  /* In 1 of 101 games the game crashes instantly. */
  if (divisible(hash, 101))
     return 0;
 
  /* Use the most significant 52-bit from the hash
     to calculate the crash point */
  var h = parseInt(hash.slice(0,52/4),16);
  var e = Math.pow(2,52);
 
  return Math.floor((100 * e - h) / (e - h));
}

 

The chain could be generated with code such as:

 


var serverSecret =  'If you knew this, you could steal all my money';
var clientSeed = '0000examplehash';
 
var gamesToGenerate = 1e7;
 
var serverSeed = serverSecret;
 
for (var game = gamesToGenerate; game > 0; --game) {
  serverSeed = genGameHash(serverSeed);
  console.log('Game ' +  game + ' has a crash point of ' + (crashPointFromHash(serverSeed, clientSeed) / 100).toFixed(2) +'x', '\t\tHash: ' + serverSeed);
}
 
var terminatingHash = genGameHash(serverSeed);
 
console.log('The terminating hash is: ', terminatingHash);

 

 

Using our chosen starting serverSeed, the hash terminating the chain is c56c9fe892bd23ff6d20da0b505c86db9acecb6a257a2b79b23dfface1d4ea75. That is to say, the first game's hash played under the new provably fair scheme, when hashed will be c56c9fe892bd23ff6d20da0b505c86db9acecb6a257a2b79b23dfface1d4ea75.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.