If you run games of chance online, fairness isn’t just a promise, it’s a verifiable guarantee you have to deliver on every single spin, roll, or deal. A provably fair RNG gives your players cryptographic receipts they can check themselves, without trusting you or a third party. In this guide, you’ll learn how to design that system end to end: how seeds and nonces fit together, how to derive unbiased outcomes, how players verify results, and how to keep the whole thing secure and compliant at scale.
What Provably Fair Means And Why It Matters
Provably fair means every bet’s randomness can be independently verified by the player using public inputs plus cryptographic commitments you published before the outcome was known. No secret sauce, no blind trust, just math.
The model rests on three pillars:
- Pre-commitment: You commit to a secret server seed ahead of time by publishing its hash. Players can’t reverse that hash to learn the seed, and you can’t change the seed later without breaking the commitment.
- Player participation: The player contributes their own client seed (and you track a nonce). That way the final randomness isn’t solely under your control.
- Transparent verification: After settling the bet, you reveal the server seed. Anyone can recompute the outcome from the seeds and nonce and confirm it matches the result they saw.
Why it matters: it eliminates the classic conflict of interest in online casinos. Your house edge can be visible in the paytable, not hidden in biased randomness. When you give players the tools to verify, disputes shrink, session trust rises, and your support team has hard evidence when questions pop up.
System Architecture: Seeds, Commitments, And Nonces
Your provably fair RNG architecture starts with clean separations of responsibility and time: commit early, combine at playtime, reveal afterward.
Server seed: You generate a high-entropy server seed inside your backend. Think 256 bits or more from a FIPS-validated or OS-grade CSPRNG. Immediately derive a commitment by hashing the seed with a collision-resistant function (e.g., SHA-256), and store both. Publish only the hash to the player before any bets linked to that seed.
Client seed: The player provides a client seed (you can auto-suggest one and let them edit). You store the exact string as part of their session. A good UX shows the current client seed and lets players rotate it whenever they want.
Nonce: The nonce increments per wager (or per game action) under a given seed pair. For multi-draw games, like card deals or multiple dice in one round, you can use draw indices plus to the per-bet nonce. The goal is deterministic uniqueness: every draw maps to a unique tuple of (server seed, client seed, nonce, draw index).
Commit–reveal flow:
- Before play: Publish server-seed hash + accept/record client seed.
- During play: Derive randomness from the tuple: record results with the current nonce.
- After seed rotation: Reveal the server seed: players verify past bets: start a new server seed with a new commitment.
Audit trail: Store the server seed, its hash, the client seed, nonces, outcomes, and timestamps. This trail is what your fairness page and support team rely on for verifications.
From Seeds To Outcomes: Deriving Unbiased Randomness
Your main task is transforming the input tuple into unbiased, uniform random values and mapping them to game outcomes without skew. The typical pattern is a keyed hash or HMAC function, followed by a bias-free mapping.
Combine inputs: Use HMAC with the server seed as the key and a canonical string as the message. The message should include the client seed, nonce, and draw index in a consistent, documented order. HMAC-SHA-256 is a common choice because it’s widely audited and efficient. The output gives you 256 bits of pseudorandom data deterministically tied to the inputs.
Extract numbers: You can slice the HMAC output into chunks (for example, 4 or 8 bytes) to generate unsigned integers. If a single draw needs more entropy than one chunk provides, hash again with an incremented counter as an additional input to expand the stream while staying deterministic.
Eliminate modulo bias: Direct modulo can skew results when the range doesn’t divide 2^n evenly. Use rejection sampling: compute a threshold equal to floor(2^k / N) * N for an N-sized outcome space. If your k-bit integer is below the threshold, take value mod N: otherwise, discard and draw another k-bit integer. This guarantees uniformity across outcomes.
Map to games:
- Roulette or number wheel: Map a uniform integer into 0–36, then apply house rules (green zero, payouts) separately from the RNG.
- Cards: Use the random stream to shuffle with a Fisher–Yates method or to draw unique indices from a 52-card deck without replacement. Determinism is crucial: the same seeds and nonce must recreate the exact shoe state and order.
- Dice and crash multipliers: Convert uniform integers to floating-point ranges carefully. For crash-like games, derive a rational or fixed-point representation first, then format for display. Avoid floating-point rounding surprises by sticking to integers until the final step.
Document your mapping: Publish the exact input formatting, HMAC choice, byte order, rejection rules, and any counters. Players and third-party tools need these details to reproduce results byte-for-byte.
Verification Pipeline: How Players Check Every Bet
Verification should feel simple even if the cryptography underneath is not. You’ll give players the inputs and steps they need, and they should be able to recreate the outcome with an external tool or your on-site verifier.
Pre-bet stage: Players see the current server seed hash and their client seed. You can pin these at the top of the game UI alongside the current nonce. Make it obvious when seeds rotate.
Post-bet details: For each settled bet, expose an immutable record showing the client seed, nonce used, the revealed server seed (after rotation), and the computed outcome. Include the exact input string your system hashed.
Reproduction steps players take:
- Confirm the server seed’s hash matches the pre-bet commitment you published.
- Plug the server seed (as key) and the concatenated client seed + nonce + draw index (as message) into HMAC-SHA-256.
- Convert the resulting hex to integers in the documented byte order.
- Apply the same rejection sampling to map into the game’s outcome space.
- Compare with the displayed result. It should match exactly.
Tooling: Offer a lightweight, open-source verifier page that runs client-side. It should accept the same parameters and show intermediate values to aid support. Also encourage third-party verification tools by documenting your spec.
Handling multi-draw bets: Show per-draw indices and outcomes for transparency. For example, if you deal five cards, display how draw indices 0–4 map to the exact cards pulled from the shuffled deck.
Security And Operations: Entropy, Key Management, And Monitoring
A provably fair RNG is only as strong as the way you generate and protect seeds, and how you monitor for anomalies.
Entropy: Generate server seeds using a cryptographically secure RNG from the OS or a hardware RNG, and mix multiple sources when available. For production, keep seeds to at least 256 bits to resist brute-force attempts on unrevealed seeds. Never reuse a server seed once revealed.
Key handling: Treat server seeds as secrets in transit and at rest. Limit access to a small service role, encrypt at rest, and rotate regularly on a schedule or bet count. Separate duties: the system that commits and reveals should be automated and auditable, not manual.
Client seed UX: Encourage players to customize their client seed. Show when it changes. If you auto-generate, make it clearly random and keep it stable until the player edits or a new session starts.
Monitoring and alerting:
- Track the distribution of outcomes continuously and alert if it deviates from statistical expectations. You’re not trying to prove fairness statistically, that’s what the cryptography is for, but drift can reveal implementation bugs.
- Log every commitment and reveal with signatures and timestamps so you can prove the sequence of events. Immutable logs or write-once storage helps.
- Watch for nonce desynchronization, repeated tuples, or failed verifications. These are red flags for race conditions or logic errors.
Disaster hygiene: If a seed leaks early, immediately rotate to a new server seed and flag all affected bets for easy player verification. Transparency earns trust even when things go sideways.
Advanced Models And Compliance Considerations
As your catalog expands, you’ll run into edge cases and regulatory expectations that go beyond the basic flow.
Advanced models:
- Multi-party randomness: Include a public beacon (like NIST or a blockchain VRF) as an additional input. It’s not a substitute for your commit–reveal but provides extra assurance that neither side alone controls outcomes.
- Verifiable delay functions: For rare, high-stakes events, you can derive randomness that can’t be known until a set time passes. That prevents early peeking even if a seed leaks inside your operation.
- Per-bet server seeds: Instead of a single server seed per session, generate a fresh server seed per wager, commit to its hash right before the bet, and reveal immediately after. This reduces blast radius but demands tight performance and logging.
Compliance:
- RNG certification: Many jurisdictions still require third-party lab testing of your RNG and game mappings, even if they’re provably fair. Provide your spec, tests, and sample vectors for review.
- Cryptography policy: Some regulators restrict algorithm choices or mandate minimum key sizes. Stick to mainstream primitives like SHA-256 or SHA-3 and HMAC: avoid custom crypto.
- Player disclosures: Your fairness page should explain, in plain language, how seeds, nonces, and verification work, with examples players can run. Accessibility matters here.
- Data protection: Treat seeds and logs as personal data if they can be tied to a player. Apply retention limits, access controls, and regional data policies (GDPR, CCPA) where applicable.
Performance and cost: Since each outcome uses an HMAC and sometimes multiple draws, optimize carefully, streamline your input formatting, reuse parsed states, and batch verifications in your UI without compromising determinism.
Frequently Asked Questions
What is a provably fair RNG and how does it work?
A provably fair RNG lets players verify every bet using cryptographic commitments and public inputs. The casino pre-commits to a server seed by publishing its hash, the player supplies a client seed, and a nonce increments per wager. After results, the server seed is revealed so outcomes can be recomputed and matched.
How do seeds and nonces produce unbiased outcomes without modulo bias?
Combine the server seed (as HMAC key) with a canonical message containing the client seed, nonce, and draw index. Use HMAC-SHA-256 to derive pseudorandom bytes. Map numbers via rejection sampling—compute a threshold and discard values above it—so mappings to wheels, cards, or dice are uniform and deterministic.
How can players verify each bet in a provably fair RNG?
Players confirm the published server-seed hash, then after reveal, recreate the HMAC-SHA-256 using the server seed, client seed, nonce, and draw index. They convert the hex output to integers in the documented byte order, apply the same rejection sampling, and compare with the displayed result. An open-source on-site verifier helps.
What security and compliance practices are essential when deploying this system?
Generate 256-bit seeds from a CSPRNG, treat seeds as secrets, encrypt at rest, and rotate on a schedule or bet count. Monitor outcome distributions, log every commitment and reveal immutably, and watch for nonce reuse. For compliance, provide specs, sample vectors, plain-language disclosures, and meet lab certification requirements.
Is a provably fair RNG better than a traditional certified RNG for online casino fairness?
They address different needs and work best together. Certification validates implementation against standards and regulations, while a provably fair RNG gives per-bet transparency players can verify themselves. It doesn’t change RTP or the house edge; it proves randomness integrity so your advantage resides in the paytable, not hidden bias.

No responses yet