Level up. Article complete. Every draw you run can now be checked, step by step.
Engineering Fairness

How commit-reveal draws work

We lock the winner seed before anyone plays, draw from it, then reveal it. Here is each step, and how your team re-checks a draw.

sha256(seed) 1 · COMMIT 2 · DRAW seed 3 · REVEAL

A prize draw has one awkward property. The people who run it are the people who could rig it. “Trust us” is a weak answer when the prize is real, so Keliplay draws are built so that the result can be checked after the fact, by recomputing it from scratch.

The technique is called commit-reveal. It has three steps, and then a fourth for you.

Commit: lock the seed before anyone plays

Every draw starts from a secret random value, the server seed: 32 random bytes, written as hex. When a game instance is activated, before a single entry exists, the server publishes the SHA-256 hash of that seed. The hash is the commitment.

A hash works like a sealed envelope. Anyone holding the seed can recompute the hash and see that it matches. Nobody holding only the hash can work out the seed. And because the commitment is published before the pool fills, the seed can’t have been picked after looking at who entered.

Draw: every value comes from the seed

When winners are picked, each random value is derived from the seed and nothing else that could be changed later. The server computes an HMAC-SHA256 keyed with the seed over three things: a client seed, a nonce, and a cursor.

  • The client seed defaults to a hash of the eligible entries, so the draw is bound to the exact pool it ran against.
  • The nonce counts draws, so one commitment covers many draws without repeating.
  • The cursor counts steps inside one draw, so a draw with five winners can be replayed step by step.

The first 13 hex characters of that HMAC become a number between 0 and 1. Thirteen hex characters are 52 bits, exactly the precision of a standard double, so the conversion gives the same answer in any language your team verifies in.

seed the key HMAC-SHA256 client seed : nonce : cursor 0 to 1 first 52 bits
One draw value. Replaying the same inputs always gives the same value.

Reveal: the seed comes out, a new one goes in

While a seed is live, publishing it would let someone predict the instance’s next draws. So it stays secret until it is rotated. Rotation reveals the old seed and commits to a new one in the same transaction, so there is never a moment where a draw could read a seed that has already been published as spent.

Once revealed, the old seed turns every past draw made with it into something your team can recompute. Future draws stay unpredictable, because they use the new seed.

Check: how your team re-runs a draw

Checking is for you, the brand running the campaign. The details of every draw are available to your team through the authenticated API, to anyone whose role can read results. There is no public page for players. What you get back for a run:

  • the published commitment, serverSeedHash
  • the clientSeed, the nonce and the entriesHash for the pool
  • the revealed serverSeed, once the seed has been rotated (until then it is null)
  • the winners exactly as recorded

The check itself is short. First, confirm the revealed seed matches the commitment. If it doesn’t, the seed was swapped, and nothing after that matters:

// the check that everything else depends on (simplified)
import { createHash, timingSafeEqual } from 'node:crypto'

function seedMatchesCommitment(serverSeed, serverSeedHash) {
  const actual = createHash('sha256').update(serverSeed).digest()
  const expected = Buffer.from(serverSeedHash, 'hex')
  return actual.length === expected.length && timingSafeEqual(actual, expected)
}

Then recompute the pool hash from the eligible entries, replay the draw with the same seed, client seed and nonce, and compare the winners with the ones recorded. The verifier depends on nothing but those inputs. No database, no clock. It either reproduces the recorded winners exactly or names what diverged.

What this does and doesn’t prove

It proves The seed was fixed before the pool existed, and wasn't swapped afterwards.
It proves The winners came from the recorded pool, by the recorded method, with no re-rolls.
It doesn't prove That every entry was a fair play. That is the integrity layer's job: runs that look forged are excluded before the draw.
It doesn't prove Anything to players on its own. Verification is yours to run, and yours to share if you choose.

Put together, the promise is narrow and solid: the draw you can check is the draw that happened.

Keep reading