Dice guide
Medusa Dice: turning a hash into a roll
"Medusa" is how this page is filed, and it has no bearing on the rules. The page follows one roll from raw hash output to the final number, one step at a time, and looks closely at how even the mapping is.
The pipeline in four steps
- Compute HMAC-SHA256 with the server seed as the key and the text
client seed:nonce:0as the message. The digest is 32 bytes, shown as 64 hex digits. - Take the first 4 bytes (8 hex digits) and read them as an unsigned whole number from 0 to 4,294,967,295.
- Divide by 2 to the power 32 (4,294,967,296) to get a float from 0 up to, but not including, 1.
- Multiply by 10,000, round down, and divide by 100. The result is the roll, from 0.00 to 99.99.
| Server seed (revealed later) | medusa-srv-4c19e2 |
|---|---|
| Commitment shown before play: SHA-256(server seed) | b83e4b1b3d1acfcc984589975cd2b8bf84d2b2e58fa285e93eafb365454dc972 |
| Client seed : nonce : round | medusa-player-07:41:0 |
| HMAC-SHA256(server seed, message) | ab4d6a18114b1e605d76c9e79faa4e8b267033cadd5f931ae8f027942ce801fb |
| First 4 bytes (8 hex digits) | ab4d6a18 = 2,873,977,368 |
| Float = value / 2^32 | 0.6691500004 |
| Dice roll = floor(float x 10,000) / 100 | 66.91 |
| Bet 'under 27.50' | loss |
One common construction, shown for teaching. Real services document their own message format; check theirs before verifying.
Why four bytes are enough
Four bytes give 4,294,967,296 possible values. Spreading them over 10,000 rolls leaves about 429,496 raw values per roll. That is far more resolution than the roll needs. Using more bytes would not make the game fairer in any way a player could notice.
The small unevenness
Because 4,294,967,296 does not divide evenly by 10,000, the rolls cannot all get exactly the same number of raw values. With the floor mapping, 7,296 of the rolls receive 429,497 raw values each, and the other 2,704 receive 429,496. The relative difference is one part in 429,496, about 0.00023%.
For any target, the true chance therefore differs from the stated chance by less than one part in 429,496 of itself. That is many orders of magnitude smaller than the house edge. It is worth knowing about, because it shows that the mapping step is a real design choice, but it does not change the practical odds.
Where things can go wrong
- Reading bytes in the wrong order. The example reads them big-endian, highest byte first. Reading little-endian gives a different number and a different roll.
- Using a different message format. A colon between the parts, or a missing round counter, changes the whole digest.
- Rounding instead of flooring. Rounding to the nearest hundredth can produce 100.00, which is outside the range, and shifts every boundary by half a step.
Each service documents its own construction. The one shown here is a common pattern used for teaching. To verify a real roll, follow that service's published method exactly, as described on the hash fairness guide.