alexcambose / provably-fair-example Goto Github PK
View Code? Open in Web Editor NEWProvably fair implementation done in javascript.
Home Page: https://medium.com/@alexcambose/provably-fair-system-in-javascript-6457e028d2aa
License: MIT License
Provably fair implementation done in javascript.
Home Page: https://medium.com/@alexcambose/provably-fair-system-in-javascript-6457e028d2aa
License: MIT License
Correct me if I am wrong, but I think 99 will have biggest chance to be rolled, because it has chance of being rolled as every other number + chance that all substrings converted to number will be over 1e6.
const getResult = hashedValue => {
// the offset of the interval
let index = 0;
// result variable
let result;
do {
// get the decimal value from an interval of 5 hex letters
result = parseInt(hashedValue.substring(index * 5, index * 5 + 5), 16);
// increment the offset in case we will need to repeat the operation above
index += 1;
// if all the numbers were over 999999 and we reached the end of the string, we set that to a default value of 9999 (99 as a result)
if (index * 5 + 5 > 129) {
result = 9999;
break;
}
} while (result >= 1e6);
// the result is between 0-999999 and we need to convert if into a 4 digit number
// we a apply a modulus of 1000 and the 4 digit number is further split into a 2 digit number with decimals
return [result % 1e4] * 1e-2;
};
https://github.com/alexcambose/provably-fair-example/blob/master/routes/api.js#L19
* It doesn't return the hashed serverseed in advance, because that would
* allow the client to generate all the rolls in advance.
Should be:
* It doesn't return the *unhashed* serverseed in advance, because that would
* allow the client to generate all the rolls in advance.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.