# Roulette

There are 15 possible outcomes on Roulette. The result 0 will always be green, while the other results (from 1 to 14) correspond to other colors.\
\
Each day a string of random letters and numbers is generated that will be used to generate all the results for that day. We call this a Seed or Secret.\
\
Normally, each seed is used for 24 hours; it is hidden as long as it is used. Instead, we show the SHA256 hash of the seed below.\
\
It is important to note that because we generate the seed at the beginning of the day, this means that all the results are predefined, and we cannot change the results of the round during the day. Therefore, you have an absolute guarantee that the rounds you play are truly random and unaffected by external factors.\
\
Since the SHA256 function is deterministic (meaning that it will always output the same result for the same input data), we can cryptographically prove the claim we make above.\
\
In addition to Seed, each round has a unique Round Number or Nonce. This number is added to the end of the Seed each round. As a result, a string in the format {seed}:{nonce} will determine the outcome of the round.\
\
The following code is written in JavaScript and can run on Node.js 10 and above:

```
const secret = "Replace this with the UNHASHED seed of the day";
const nonce = "Replace this with the round's number";

function getRandom({ secret, nonce, divisions = 15 }) {
    const fullSeed = crypto
        .createHash("sha256")
        .update(`${secret}:${nonce}`)
        .digest("hex");

    const seed = fullSeed.substr(0, 8);

    return parseInt(seed, 16) % divisions;
}

console.log(
    `${getRandom({ secret, nonce })} is the outcome ("random") of this round`
);
```
