jonnify·codemojex /codemojex/rooms-and-modes/the-secret-and-its-commitment

Codemojex · C2.3

The secret and its commitment.

A game draws a secret of six distinct codes from its snapshotted keyboard. The secret is a server-side column, selected by no player-facing query. A blind golden game commits to it at open and discloses it at close — so a game a player must trust becomes a game a player can check.

Grounding — Codemojex.Rooms (seal_commitment/3 · commit/2 · close_sealed/2) · schemas/game.ex · the golden-blind story.

What crosses the wire, and what stays sealed — across a blind game’s life
1 · at open PUBLIC commitment = SHA-256(secret‖nonce) SEALED secret nonce 2 · in-flight PUBLIC state · timer (no per-guess score) SEALED secret · nonce scores 3 · at close PUBLIC secret · nonce board · payouts SEALED — disclosed
at open → a golden game computes commitment = SHA-256(secret ‖ nonce) and may publish the commitment. The secret and nonce stay sealed server-side.
§1

The drawn secret

rooms.ex · game.ex

start_game/3 draws secret = EmojiSet.secret_from(cell_codes) — six distinct codes from the game’s snapshotted keyboard. The games row stores the secret and cell_codes; the schema moduledoc states it in plain terms: the secret is a server-side column and is never serialized to players.

No player-facing view selects it — the privacy boundary is structural, not a filter at the edge (C1.3). A classic game keeps the secret and pays live; a golden game seals it under a commitment and discloses it once, at close.

§2

The commitment

commit/2

A commitment is a promise the server cannot later alter. seal_commitment/3 draws a nonce (16 random bytes as 32 hex chars) and hashes the secret with it. Step through the preimage the hash is taken over.

The commitment builder — the preimage, then the hash
preimage = code0 ‖ … ‖ code5 ‖ nonce (joined by US, 0x1e) 0305 0904 0801 0610 0007 0213 nonce · 32 hex chars SHA-256 6896208bd5f4b76b7fcbf56c3d8486cba37c68366dd32d86459424961e360100
the six codes → the preimage begins with the drawn secret — six distinct XXYY codes.
iex · Codemojex.Rooms.commit/2 session
iex> secret = ["0305", "0904", "0801", "0610", "0007", "0213"]
iex> nonce  = "9f2c1ab7d4e6083f5c1904ea2b7d6c8e"
iex> Codemojex.Rooms.commit(secret, nonce)
"6896208bd5f4b76b7fcbf56c3d8486cba37c68366dd32d86459424961e360100"
§3

Reveal and verify

close_sealed/2

At close the sealed pass sets status: :revealing, stamps revealed_ms (the privacy gate opens), pays the top-K their split, and broadcasts one event carrying the secret, the nonce, the commitment, the final board, and the payouts. Any player recomputes SHA-256(secret ‖ nonce) and checks it against the commitment fixed at open. Because the commitment bound the server before any guess was made, the check needs no trust.

golden-blind story · test/stories/golden_blind_story_test.exs acceptance
Scenario: the sealed close reveals the secret and the commitment verifies
  Given a golden game with a scored guess, subscribed for the disclosure
  When  the game is closed (the sealed pass runs)
  Then  one event arrives whose secret + nonce recompute
        to the published commitment

The blind mode also has an anti-abuse edge: with no per-guess signal, a feedback-driven bot cannot hill-climb toward the secret, and the all-pay fee gives blind farming a negative expected value.

§4

References

sources · related

Sources

Related