Keno guide
Royal Keno: from a hash to ten different numbers
Royal is a naming choice for this page and has no bearing on the rules. The page covers the mechanics of a verifiable keno draw: how one secret seed can produce 10 distinct numbers out of 40 that anyone can recheck later.
What has to happen
A keno draw needs 10 different numbers from 1 to 40, with every set of 10 equally likely. There are 847,660,528 such sets. A hash-based service must produce one of them in a way that it fixed before you placed your ticket, and in a way you can repeat with the revealed inputs.
The ingredients
- Server seed. A secret string chosen by the service. Before play, only its SHA-256 hash is shown. That hash is the commitment.
- Client seed. A string the player can set. It stops the service from choosing a server seed that suits one known client input.
- Nonce. A counter that goes up by one for each round, so the same pair of seeds gives a new draw every time.
The worked example
| Server seed (revealed later) | royal-keno-srv-91c2e0 |
|---|---|
| Commitment shown before play: SHA-256(server seed) | 4d7310609f8d45a377091e9bf305ed0fda42804cce2ff902221943452a6e27ac |
| Client seed : nonce : round | royal-reader-04:7:0 |
| HMAC-SHA256(server seed, message) | 56d5f1df6725ccf72717468518be749c06e66e3748752f90a107ce11217bdecc |
| First 4 bytes (8 hex digits) | 56d5f1df = 1,456,861,663 |
| Float = value / 2^32 | 0.3392020387 |
| 10 floats, each picks from the numbers not yet used | 14, 17, 6, 4, 1, 13, 28, 8, 11, 19 |
| Drawn numbers, sorted | 1, 4, 6, 8, 11, 13, 14, 17, 19, 28 |
One common construction, shown for teaching. Real services document their own message format; check theirs before verifying.
The table shows only the first float in full. The draw needs 10 floats, one per drawn number. In this construction they come from consecutive 4-byte slices of HMAC-SHA256 outputs, each turned into a number between 0 and 1 by dividing by 2^32.
Why no number can repeat
The trick is a shrinking pool. Start with the list 1 to 40. The first float picks a position in that list: floor(float x 40). That number is drawn and removed. The second float picks a position in the 39 that remain, the third in 38, and so on down to 31 for the tenth. Because each chosen number leaves the list, it cannot be picked again. This is the same idea as drawing balls from a drum without putting them back.
It also gives every set the right weight. The first pick has 40 equal options, the second 39, and so on. Multiply them and divide by the 10! orders in which the same set could arise, and you get back C(40, 10). Each set is reached equally often.
A small rounding effect
A 4-byte value has 2^32 possible values. Splitting them into 40, 39 or 38 equal parts is not exact, so a few positions get one extra value. The excess is at most one part in 107,374,182 for the first pick, far too small to matter in practice, but it is the reason some services use more bytes per float.
How to check a real draw
- Save the commitment hash before you play.
- After the server seed is revealed, hash it with SHA-256 and compare it with the saved commitment.
- Recompute the HMAC for your client seed and nonce, using the message format the service documents.
- Turn the bytes into floats and run the shrinking-pool draw. Your 10 numbers should match the ones shown.
The general method is described on the hash fairness guide. Note that verification proves the draw was fixed in advance; it says nothing about whether the pay table is generous.