**Provably Fair**

**Note:** This system is only for the Dragon Wheel. There is no randomness involved for the match betting section.
We use a provably fair system for all of our rolls. These special algorithms determine the winner of all matches and ensure that operators cannot change the results of a match in progress. All variables are determinant and transparent. We provide our techniques so you can manually calculate the winner of a previous match yourself.

### Daily Secret

We generate a new *daily secret hash* every day when the date changes. The secret from the previous day is revealed a few minutes after the day has changed. The daily secret hash is a sha256 hash of some entropy on the server. The secret hash looks like this:

113171565a6939814d24bc8422affd836946bedbee1e0cc2f11d986c0653562dYou can view the list of all the daily secrets. We reveal the secret when the date changes.

**All**random rolls depend on this value.

### Winning Percent

When a match is created, a match ID is generated by the server and shown to all players. The wager amount and the IDs of all players are also known. The daily secret is known by the server, but not by the players until tomorrow. We combine all of these values together in to a single string and take the sha256 hash of that string. This results in a long number represented in hexidecimal form. We take the last 13 hex characters of that number, then convert it to a decimal number. We divide this number by the maximum amount it can be, then multiply it by 100 to get a value between 0.0 and 100.0. This is called the winning percent and it is used by all gamemodes to determine the winner, although each gamemode uses the winning percent differently.

### Dragon Wheel

Winning Percent | Winner |
---|---|

<= 0.03703703703703703% | Red |

<= 0.2222222222222222% | Green |

<= 0.5308641975308641% | Blue |

> 0.993827160493827 | White |

### Code

Our code looks something like this. Feel free to verify results on your own.```
/*
matchid: The public matchid
secret_hash: The secret hash for today
wager: The total wager put up by all participants
*/
function getDragonWheelWinningPercent(matchid, secret_hash, wager) {
var sha256 = sha('sha256')
var hash = sha256.update(
matchid + ':' +
secret_hash + ':' +
wager
).digest('hex')
return parseInt('0x' + hash.substr(-13)) / 0xfffffffffffff * 100
}
// 1 = white, 2 = blue, 3 = green, 4 = red
// The wheel spin visuals are calculated differently but the end result is the same.
function getDragonWheelResult(winning_percent) {
winning_percent /= 100
if (winning_percent <= 1 / 54)
return 4
if (winning_percent <= 11 / 54)
return 3
if (winning_percent <= 28 / 54)
return 2
return 1
}
```

I also agree that, in order to play using Embers, I am residing in a place that allows it.