Mines guide
Space Mines: placing the mines from a hash
The Space label on this page is cosmetic. The game is standard mines. This page shows how a hash-based service can fix all mine positions before the first tile is turned over.
Why placement must be fixed in advance
In mines the danger is that the board could be set after the player picks. A service that moved a mine under the chosen tile would win every time. A commit-reveal scheme rules that out. The service commits to a server seed by publishing its SHA-256 hash, the positions are computed from that seed, and the seed is revealed after the round so anyone can recompute the board.
From floats to tiles
The method below needs one random float per mine. Number the tiles 1 to 25. The first float picks one tile from all 25: tile index = floor(float x 25). That tile is removed from the pool. The second float picks from the 24 tiles left, and so on. Removing each chosen tile guarantees distinct positions and gives every set of mine positions the same chance.
| Server seed (revealed later) | space-mines-srv-04e1 |
|---|---|
| Commitment shown before play: SHA-256(server seed) | 8d50dbc9a6d09ab264271041ad0eeb14b3af1d05303a33c6b69ed03c34e4f1c1 |
| Client seed : nonce : round | space-reader-2b:31:0 |
| HMAC-SHA256(server seed, message) | 52f65e36d8891b6f89cc44b235d986b4b9feb16a1ee7261c5323f0ed0da8ca12 |
| First 4 bytes (8 hex digits) | 52f65e36 = 1,391,877,686 |
| Float = value / 2^32 | 0.3240717775 |
| 6 floats, each picks from the numbers not yet used | 9, 22, 14, 5, 19, 3 |
| Mine positions (tiles numbered 1-25), sorted | 3, 5, 9, 14, 19, 22 |
One common construction, shown for teaching. Real services document their own message format; check theirs before verifying.
Seeing the board
The six mine positions above can be drawn on a 5 x 5 grid, reading rows left to right from tile 1. The sorted list in the last row is what you would compare against the board shown after the round. Tile 1 is the top-left corner, tile 5 the top-right, and tile 25 the bottom-right. If even one position differs, the board was not built from the committed seed.
Check it yourself
- After the round, copy the revealed server seed. Hash it with SHA-256 and match it to the commitment.
- Build the message from your client seed and nonce in the documented format.
- Compute HMAC-SHA256 keyed with the server seed. Split the output into 4-byte pieces and divide each by 2^32.
- Use the floats in order to pick from the remaining tiles, removing each pick.
- Compare the resulting tiles with the board you were shown.
Common questions
Does the order I reveal tiles in matter?
No. In this construction every mine position is fixed before the first reveal. Your choices only decide which of those fixed tiles you uncover.
Can the service see my picks before placing mines?
Not if the commitment was published first. The positions follow from a seed that was locked by its hash.
What if more floats are needed than one digest gives?
One HMAC output gives eight 4-byte floats. For more mines the round counter in the message goes up by one and a new digest supplies the next eight.
The general idea, for every game type, is on the hash fairness guide.