var sha256 = require('sha256');
var seed = 'f0c82c85ba6ef5cbba7406db81ee5451a1a795120e335116dc637d34a105e6e6';
function fair_getHash256(seed){
return sha256(seed);
}
console.log('Hashed: ' + fair_getHash256(seed));
var crypto = require('crypto');
var roll_server_seed = 'aed859a82f458f3111fb8dd813001a65a9d88fce5004a37a3648a4f3c745e9df';
var roll_public_seed = '3e2a4be2d0eb744ea4b07b2773f881f035f84f5fcb1880ceb25929ad7563df34';
var roll_nonce = 0;
function fair_getCombinedSeed(server_seed, public_seed, nonce) {
return [server_seed, public_seed, nonce].join('-');
}
function fair_generateSaltHash(seed) {
return crypto.createHmac('sha256', seed).digest('hex');
}
function fair_getRoll(salt, max) {
return Math.abs(parseInt(salt.substr(0, 12), 16)) % max;
}
var generated_seed = fair_getCombinedSeed(roll_server_seed, roll_public_seed, roll_nonce);
var generated_salt = fair_generateSaltHash(generated_seed);
var generated_roll = fair_getRoll(generated_salt, 15);
console.log('Roll: ' + generated_roll);
var crypto = require('crypto');
var roll_server_seed = 'e581f85cab4f8f4ee22afc82b8299c4bd7f132049c9212b32e989b798246ac31';
var roll_public_seed = '1b233defb3b6acc3ead30a62ded768e8db9950bb922db728f44dcf9fb464d21e';
var roll_nonce = 0;
function fair_getCombinedSeed(server_seed, public_seed, nonce) {
return [server_seed, public_seed, nonce].join('-');
}
function fair_generateSaltHash(seed) {
return crypto.createHmac('sha256', seed).digest('hex');
}
function fair_getRollCrash(salt){
var INSTANT_CRASH_PERCENTAGE = 5.00;
// Use the most significant 52-bit from the salt to calculate the crash point
var h = parseInt(salt.slice(0, 52 / 4), 16);
var e = Math.pow(2, 52);
var result = (100 * e - h) / (e - h);
// INSTANT_CRASH_PERCENTAGE of 5.00 will result in modifier of 0.95 = 5.00% house edge with a lowest crashpoint of 1.00x
var houseEdgeModifier = 1 - INSTANT_CRASH_PERCENTAGE / 100;
var endResult = Math.max(100, result * houseEdgeModifier);
return Math.floor(endResult);
}
var generated_seed = fair_getCombinedSeed(roll_server_seed, roll_public_seed, roll_nonce);
var generated_salt = fair_generateSaltHash(generated_seed);
var generated_roll = (fair_getRollCrash(generated_salt) / 100).toFixed(2);
console.log('Roll: ' + generated_roll);
var crypto = require('crypto');
var roll_server_seed = 'cc0fa67554c2e9fc0f6a4a833353080a6f0e7dd2e8a911efb8f6f05c75a93063';
var roll_client_seed = '0d3ec17f8e156a06656107778fbb83211d96c8686bcaa6f0a957baf18ca21b5f';
var roll_nonce = 5;
function fair_getCombinedSeed(server_seed, public_seed, nonce) {
return [server_seed, public_seed, nonce].join('-');
}
function fair_generateSaltHash(seed) {
return crypto.createHmac('sha256', seed).digest('hex');
}
function fair_getRoll(salt, max) {
return Math.abs(parseInt(salt.substr(0, 12), 16)) % max;
}
var generated_seed = fair_getCombinedSeed(roll_server_seed, roll_client_seed, roll_nonce);
var generated_salt = fair_generateSaltHash(generated_seed);
var generated_roll = fair_getRoll(generated_salt, Math.pow(10, 8)) / Math.pow(10, 8);
console.log('Roll: ' + generated_roll);
var crypto = require('crypto');
var roll_server_seed = '48dc637aedd2d53c1dbf4d0cb8c48e3be1a243a6fb9e6738cd528cef1db1159e';
var roll_public_seed = '11db6dc55673ab3d610ee1b96593a08ed5029231f4a0fa1e8d54e1b4abd34c5f';
var roll_nonce = 3;
var roll_rounds = 4;
var roll_players = 2;
function fair_getCombinedSeed(server_seed, public_seed, nonce) {
return [server_seed, public_seed, nonce].join('-');
}
function fair_generateSaltHash(seed) {
return crypto.createHmac('sha256', seed).digest('hex');
}
function fair_getRoll(salt, max) {
return Math.abs(parseInt(salt.substr(0, 12), 16)) % max;
}
function fair_getRollCaseBattle(salt, rounds, players) {
var array = [];
for(var i = 0; i < rounds; i++) {
array.push([]);
for(var j = 0; j < players; j++) {
var salt_position = fair_generateSaltHash(salt + '-' + i + '-' + j);
var roll = fair_getRoll(salt_position, Math.pow(10, 8)) / Math.pow(10, 8);
array[i].push(roll);
}
}
return array;
}
var generated_seed = fair_getCombinedSeed(roll_server_seed, roll_public_seed, roll_nonce);
var generated_salt = fair_generateSaltHash(generated_seed);
var generated_roll = fair_getRollCaseBattle(generated_salt, roll_rounds, roll_players);
console.log('Roll: ' + JSON.stringify(generated_roll));
var crypto = require('crypto');
var roll_server_seed = '2c3eea4603280f3cadfb0046b248e7b756930b0b6886997ac73f96d478c823f3';
var roll_client_seed = '0b3eeb63c10796f00e3faff36207b369';
var roll_nonce = 0;
function fair_getCombinedSeed(server_seed, public_seed, nonce) {
return [server_seed, public_seed, nonce].join('-');
}
function fair_generateSaltHash(seed) {
return crypto.createHmac('sha256', seed).digest('hex');
}
function fair_getRoll(salt, max) {
return Math.abs(parseInt(salt.substr(0, 12), 16)) % max;
}
var generated_seed = fair_getCombinedSeed(roll_server_seed, roll_client_seed, roll_nonce);
var generated_salt = fair_generateSaltHash(generated_seed);
var generated_roll = (fair_getRoll(generated_salt, 10000) / 100) % 100;
console.log('Roll: ' + generated_roll);
var crypto = require('crypto');
var roll_server_seed = '2c3eea4603280f3cadfb0046b248e7b756930b0b6886997ac73f96d478c823f3';
var roll_client_seed = '0b3eeb63c10796f00e3faff36207b369';
var roll_nonce = 59;
function fair_getCombinedSeed(server_seed, public_seed, nonce) {
return [server_seed, public_seed, nonce].join('-');
}
function fair_generateSaltHash(seed) {
return crypto.createHmac('sha256', seed).digest('hex');
}
function fair_getRoll(salt, max) {
return Math.abs(parseInt(salt.substr(0, 12), 16)) % max;
}
function fair_getRollPlinko(salt) {
var array = [];
//Get plinko roll by stage
for(var i = 0; i < 14; i++){
var salt_possition = fair_generateSaltHash(salt + '-' + i);
var roll = fair_getRoll(salt_possition, 2);
array.push(roll);
}
return array;
}
var generated_seed = fair_getCombinedSeed(roll_server_seed, roll_client_seed, roll_nonce);
var generated_salt = fair_generateSaltHash(generated_seed);
var generated_array = fair_getRollPlinko(generated_salt);
var generated_roll = generated_array.join('');
console.log('Roll: ' + generated_roll);