Pages:
Author

Topic: Bustabit.com Provably Fair Seeding Event - page 3. (Read 49515 times)

member
Activity: 100
Merit: 10
Vires in numeris.
January 13, 2015, 09:43:50 AM
#4
The chain could be generated with code such as:

Code:
var serverSeed = 'If you knew this, you could steal all my money'; // example
var clientSeed = '000000000000000012e8c0efdff2b8f67282e211749cc5530bd6e709f70279e1'; // determined by this seeding event

var gamesToGenerate = 100; // It'll be much larger in reality

for (var game = gamesToGenerate; game > 0; --game) {
  serverSeed = genGameHash(serverSeed, clientSeed);
  console.log('Game ' +  game + ' has a crash point of ' + (crashPointFromHash(serverSeed) / 100).toFixed(2) +'x', '\t\tHash: ' + serverSeed);
}


Using our chosen starting serverSeed, the hash chain terminating with the hash 7ebfb0e6cbfbdb4de6940fb954f4c554f388de114e04caeb5a26144458b551c1

The serverSeeds should be a pure sha256 chain without mixing the clientSeed in. Else you can't really give us the end of the chain ahead of the clientSeed Wink So
Code:
  serverSeed = genGameHash(serverSeed, clientSeed);
should in fact be
Code:
  serverSeed = sha256(serverSeed);

Also the end of the chain 7ebf.... is that the hash for determining the crashpoint of game 1 or is it the hash thereof? Please make that clear.
member
Activity: 78
Merit: 10
January 13, 2015, 05:17:03 AM
#3
this seems really good. Has it already been implemented? If not, when does it start?



You need to give us a hash of the initial server seed.

For your own sake I hope you make this seed random / long enough Wink
member
Activity: 100
Merit: 10
Vires in numeris.
January 12, 2015, 06:01:44 PM
#2
Welcome to the first provably fair seeding event. One of the most requested features of Money Pot has been to create a provably distribution of game crashes, to replace our provably predetermined multipliers.

The original scheme of turning a multiplayer game in which peers do not trust each other was first proposed by Dooglus, refined by Eric and solidified into code by Steve.

In order to ensure fairness, we need to select a client seed in a verifiable way, after we have publicised all details and cannot control the outcome of the client seed picking. This is where the seeding event comes in, we need you to witness the process to ensure nothing has changed. A good way to do this might be save the post, quote it somewhere, save a copy in some archiving services. If anyone wants me to email them a copy, PM me your email address.

Our plan is to use hash of the bitcoin block 339300 as the client seed. If anyone finds any flaws in the code or methodology, we will push the block back to accommodate.  

The technical details are as follows:

The method to convert a serverSeed and clientSeed to a game hash is quite simple:
Code:
function genGameHash(serverSeed, clientSeed) {
  return crypto.createHmac('sha256', serverSeed).update(clientSeed).digest('hex');
}

The method to convert a game hash to a money pot multiplier is a bit more complex:
Code:
function crashPointFromHash(hash) {
  // Returns an integers corresponding to the game crash. 123 = Game crashes at 1.23x

  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 - inc : 0; i < hash.length; i += 4) {
      val = ((val << 16) + parseInt(hash.substring(i, i+4), 16)) % mod;
    }

    return val === 0;
  }

  /* 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);

  /* Assuming the 52-bit prefix is uniformly distributed
     then r is uniformly distributed over [0,1). */
  var r = h / e;

  /* Perfect is the perfectly continuous distributed
     multiplier for a zero sum game. */
  var perfect    = 1 / (1 - r);

  /* Apply a house edge to the perfect distribution. */
  var houseEdge  = (perfect-1) * 0.01;
  var multiplier = perfect - houseEdge;

  // return Math.floor(multiplier * 100);

  /* Inlining and simplifying the above yields the following version
     which is slightly more numerically stable. The multiplication
     100 * e still leaves the exactly representable integers.
  */
  return Math.floor((100 * e - h) / (e - h));
}

The chain could be generated with code such as:

Code:
var serverSeed = 'If you knew this, you could steal all my money'; // example
var clientSeed = '000000000000000012e8c0efdff2b8f67282e211749cc5530bd6e709f70279e1'; // determined by this seeding event

var gamesToGenerate = 100; // It'll be much larger in reality

for (var game = gamesToGenerate; game > 0; --game) {
  serverSeed = genGameHash(serverSeed, clientSeed);
  console.log('Game ' +  game + ' has a crash point of ' + (crashPointFromHash(serverSeed) / 100).toFixed(2) +'x', '\t\tHash: ' + serverSeed);
}


Using our chosen starting serverSeed, the hash chain terminating with the hash 7ebfb0e6cbfbdb4de6940fb954f4c554f388de114e04caeb5a26144458b551c1


Just a quote to have a copy not editable by OP. Maybe somebody with higher trust can re-quote Wink
legendary
Activity: 1463
Merit: 1886
January 12, 2015, 05:50:35 PM
#1
Welcome to the first provably fair seeding event. One of the most requested features of bustabit has been to create a provably distribution of game crashes, to replace our provably predetermined multipliers.

The original scheme of turning a multiplayer game in which peers do not trust each other was first proposed by Dooglus, refined by Eric and solidified into code by Steve.

The high level of the scheme is as follows:

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: c1cfa8e28fc38999eaa888487e443bad50a65e0b710f649affa6718cfbfada4d, by publicising it here we are preventing any ability to pick an alternate sha256 chain.


2) Bustabit 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 339300.


The reference code (javascript) is as follows:

The method to create the hash chain is simply sha256:
Code:
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 money pot multiplier:

Code:
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:

Code:
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 c1cfa8e28fc38999eaa888487e443bad50a65e0b710f649affa6718cfbfada4d. That is to say, the first game's hash played under the new provably fair scheme, when hashed will be c1cfa8e28fc38999eaa888487e443bad50a65e0b710f649affa6718cfbfada4d.
Pages:
Jump to: