Dev.to Security πŸ” Cybersecurity πŸ‘ 0 πŸ“– 7 min read

Provably fair, step by step: from seeds to a result you can check

"Provably fair" is a commit-and-reveal scheme with a few extra parts bolted on. Once you see the parts, there is nothing mysterious about it: a seed is fixed and hidden behind a hash, other inputs are mixed in, the resul

"Provably fair" is a commit-and-reveal scheme with a few extra parts bolted on. Once you see the parts, there is nothing mysterious about it: a seed is fixed and hidden behind a hash, other inputs are mixed in, the result is computed by a fixed formula, and the hidden seed is shown afterwards so anyone can redo the sum.

This post builds one round piece by piece, with Node's crypto module, and ends with a real round you can reproduce on your own machine.

The five inputs

Every provably fair game we have looked at is made of the same pieces, in different arrangements:

  1. Server seed: a random string the operator generates and keeps secret while it is in use.
  2. Server seed hash: the SHA-256 of that seed, shown to the player before any bet is placed.
  3. Client seed: a string the player controls, or several strings from several players.
  4. Nonce: a counter that goes up by one with every bet made on the same seed pair, starting from 0.
  5. A formula: the fixed recipe that turns a hash into a game result.

The first four go into a hash function. The fifth reads the hash and produces a roll, a multiplier or a card.

Step 1: commit to the server seed

The operator picks a server seed and publishes only its hash:

commitment = SHA-256(server seed)

SHA-256 is one-way, so the hash tells the player nothing about the seed. It is also binding: finding a second seed with the same hash is not practical. The operator has now locked in a value it cannot quietly swap later.

With a made-up seed my-test-server-seed, the commitment is:

1622000570e59f3bf670fa2f71bf02c18093ed45941313ff27fda78d2180cdc4

Step 2: add the client seed

If the server seed were the only input, the operator could generate millions of seeds offline and keep the ones that suit it. The client seed closes that door. The player sets it (or the game fills in a random one the player may change), and the operator commits to the server seed before it knows what the client seed will be.

Games differ in how many client seeds they take. Dice-style games usually take one, the player's own. Aviator by Spribe takes three, one from each of the first three players who bet in the round, so no single side controls the input.

Step 3: count bets with a nonce

Rotating the server seed after every bet would be slow, so seed-pair games reuse the same pair for many bets and add a nonce: 0 for the first bet, 1 for the next, and so on. Same seeds, different nonce, completely different hash.

Aviator does not need a nonce. Every round gets a new server seed and new client seeds.

Step 4: hash everything together

Two constructions are common.

HMAC-SHA256, used by many seed-pair games. The server seed is the key and the message is built from the client seed and the nonce. A common layout of the message is clientSeed:nonce:0, where the last number is a cursor for games that need more than 32 bytes.

bytes = HMAC-SHA256(key = server seed, message = client seed : nonce : 0)

Plain concatenation and SHA-512, used by Aviator by Spribe:

hash = SHA-512(server seed + client seed 1 + client seed 2 + client seed 3)

The order matters. Another game sold as Aviator, by Aviator Studio, puts the server seed last instead of first and gets a different hash from the same four strings.

Step 5: turn hash bytes into a result

This is the step where games really differ, and the step most write-ups skip.

A generic dice roll. Take the first 4 bytes and read them as a fraction in base 256, which gives a number from 0 up to (but not including) 1:

f = b0/256 + b1/256^2 + b2/256^3 + b3/256^4
roll = floor(f * 10001) / 100        // 0.00 to 100.00

With our test seed, the client seed my-client-seed and nonce 0, the first four bytes are 187, 230, 238, 19, f is about 0.734, and the roll is 73.40. This is one common scheme, not a universal one. Each operator documents its own, and a check only means something with the operator's actual formula.

An Aviator multiplier (Spribe). Take the first 13 hex characters of the SHA-512 hash. Thirteen hex characters are 52 bits, so the number h sits evenly between 0 and 2^52:

multiplier = floor(97 * 2^52 / (2^52 - h)) / 100, never below 1.00

The 97 is the return the formula is built on. The integer division happens before the division by 100, which is why the result always has exactly two decimals.

Step 6: reveal and verify

When the seed pair is retired (in a seed-pair game, when the player rotates it; in Aviator, when the round ends), the server seed is shown in clear. The player then checks two things:

  1. SHA-256(revealed seed) equals the commitment from step 1. If it does, the seed was fixed before the bets.
  2. Running the formula on the revealed seed, the client seed(s) and the nonce gives the result the game showed. If it does, the result was not changed afterwards.

If either check fails, first look for a copying slip. Seeds are long, and a capital I and a small l look alike.

The whole thing in Node

No dependencies, Node 18 or newer:

import { createHash, createHmac } from 'node:crypto'

const sha256 = (s) => createHash('sha256').update(s).digest('hex')
const sha512 = (s) => createHash('sha512').update(s).digest('hex')

// Step 6, check 1: the hash shown first must come from the seed revealed later.
const committedTo = (serverSeed, shownHash) => sha256(serverSeed) === shownHash.toLowerCase()

// Steps 4 and 5 for a generic dice game: HMAC-SHA256, first 4 bytes, 0.00 to 100.00.
function diceRoll(serverSeed, clientSeed, nonce) {
  const bytes = createHmac('sha256', serverSeed).update(`${clientSeed}:${nonce}:0`).digest()
  let f = 0
  for (let i = 0; i < 4; i++) f += bytes[i] / 256 ** (i + 1)
  return Math.floor(f * 10001) / 100
}

// Steps 4 and 5 for Aviator by Spribe: SHA-512, 52 bits, multiplier.
function aviatorSpribe(serverSeed, clientSeeds) {
  const hash = sha512(serverSeed + clientSeeds.join(''))
  const h = BigInt('0x' + hash.slice(0, 13))
  const E = 2n ** 52n
  const result = Math.max(1, Number((97n * E) / (E - h)) / 100)
  return { prefix: hash.slice(0, 13), h: h.toString(), result }
}

// A real Spribe round, copied with its seeds from the game's round history.
console.log(aviatorSpribe('U6e1y4NvMnqY7LHJwRC0nA8CgnRfNqqe26s9v5BI', [
  '787b9f1ba17d3c850cad', '4ca7f4f94049f1aa1bfb', '58eadaf02bb2a41aecfa',
]))
// { prefix: 'bf66dee34b41a', h: '3367176752116762', result: 3.84 }

const seed = 'my-test-server-seed'
console.log(committedTo(seed, sha256(seed)), diceRoll(seed, 'my-client-seed', 0))
// true 73.4

Save it as pf.mjs and run node pf.mjs.

The real round, worked by hand

The Aviator round above was recorded from the game on 10 November 2026. The screen showed 3.84x. Here is the arithmetic:

Step Value
String hashed server seed + the three client seeds, 100 characters
SHA-512 begins bf66dee34b41ab8dec37...
First 13 hex characters bf66dee34b41a
As a number, h 3 367 176 752 116 762
2^52 - h 1 136 422 875 253 734
97 * 2^52 / (2^52 - h) 384.407..., floored to 384
Multiplier 384 / 100 = 3.84

The hash starts with bf, about three quarters of the way up the range, so the round landed in the middle of the scale. Change one character of any seed and the first 13 characters change completely, and so does the multiplier.

Checking many results at once

Pasting seeds one round at a time gets old fast. The bulk bet verifier takes up to 500 lines and runs the steps above on each one:

  • Aviator rows: server seed, one to three client seeds, and optionally the multiplier the game showed. Rows are checked with the Spribe formula.
  • Dice rows: server seed, client seed, nonce, and optionally the roll. These use the generic HMAC-SHA256 method from step 5, so a mismatch may only mean the operator uses a different scheme.

Values can be separated by commas, semicolons or tabs (use semicolons or tabs if your numbers have decimal commas). Every row gets a match, no match, or "computed only" mark, and the hashing runs in the browser with no uploads.

If you would rather read and run the code, the Aviator part is open source under MIT: aviator-round-verifier on GitHub. It supports both the Spribe and the Aviator Studio formulas, and npm test rebuilds six real rounds, including one the formula puts at 0.96 that the game shows at its 1.00x floor.

What a match does and does not prove

A match proves one narrow thing: the result follows from seeds that were fixed before the bet, so it was not changed afterwards. That is useful, and it is all.

  • It does not predict anything. The server seed in use is hidden, and without it there is nothing to compute. Verifying a thousand past rounds tells you nothing about the next one.
  • It does not change the house edge. The edge is written into the formula itself (the 97 in the Spribe multiplier is a 97% return, so 3% stays with the house), and a fair round is a round where that edge was applied exactly as published.
  • It does not confirm the formula is the operator's real one. You can only check a game against the formula it documents, which is why we test every formula against recorded rounds before trusting it.

Provably fair is a tool for auditing, not a reason to bet more.

This article was written with the help of AI. The formulas come from our verifier code and were tested against rounds we recorded ourselves; the snippet above was run in Node and reproduces the 3.84x round exactly.

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.