Skip to article
Four poker cards arranged over a six-seat elliptic-curve grid: one ivory ace of spades revealed to its player alongside a dark padlocked card sealed from the server.

I Built a Poker Server I Can’t Cheat On

When you host a poker game for your own friends on a server you built, an awkward thought eventually crosses your mind: if I really wanted to, I could SSH into this box and read every single hand at the table.

Obviously I wouldn’t. The UI doesn’t let the host peek, and players only receive their own cards over the socket. Still, on a normal online poker table, the server shuffles a plaintext array of 52 cards, holds everyone’s pocket aces in memory, and writes active tables to a crash-recovery snapshot on disk. Your friends aren’t trusting the math—they’re trusting that you’re a decent person.

Most “provably fair” poker sites don’t change that. They prove after the hand that the shuffle came from an unbiased combination of server and player seeds. That confirms nobody stacked the deck, which is nice. It does nothing to stop whoever owns the machine from knowing your pocket queens on the flop—or peeking at the river before you call.

I wanted Backroom to have a mode where you don’t have to take my word for it. So I built Private-Deal Hold’em: players’ own devices jointly shuffle an encrypted deck, prove they shuffled honestly, and hold the only keys capable of opening their hole cards. Both the web app and the native Flutter app verify every proof locally, with zero external cryptography dependencies.

Before writing a single line of math, though, there was one practical worry that almost talked me out of it: how slow does this feel at a real table?

The five-second pause problem

Cryptographic poker has existed on paper since Shamir, Rivest, and Adleman wrote the original “Mental Poker” memo in 1979.1 In practice, live implementations have a reputation for feeling sluggish.

To get real numbers instead of guessing from benchmarks, I timed 74 hands on Dominion, a live mental-poker site running on Midnight.2 Across three- to six-player tables, the median time from shuffle setup until players could act was 4.1 seconds (ranging from 3.7 to 7.3 seconds). From the previous pot being awarded until betting reopened, the median wait was 4.7 seconds.

Part of that pause turned out to be deliberate table pacing—their tables were configured to rest four seconds after a fold win and seven after a showdown—and the shuffle happened inside that gap. On Backroom, though, a pot won by a fold deals the next hand in 1.5 seconds. Turning a crisp 1.5-second rhythm into a mandatory five-second wait between hands would ruin the feel of the table.

The trick is realizing the shuffle doesn’t belong between hands at all.

There is no cryptographic reason to wait for Hand N to finish before shuffling the encrypted deck for Hand N + 1.3 While everyone is deciding whether to call a c-bet on the flop, their browsers and phones are sitting completely idle. So the instant a hand starts, Backroom quietly begins shuffling a fresh encrypted deck in the background for the same seats.

SEQUENTIAL (SHUFFLE BETWEEN HANDS) Hand #1 plays 1.5s rest Keys + N shuffles + proofs Open Hand #2 BACKROOM PIPELINED (PRE-PREPARED NEXT DECK) Hand #1 plays Next deck shuffled in background 1.5s rest 1 RTT ~18ms Hand #2 starts immediately (+ Deck #3 preps)
Moving the shuffle off the critical path: by the time a fold win finishes its 1.5-second chip slide, the next encrypted deck is already verified and waiting.

When the pot slides to the winner and the 1.5-second rest ends, Backroom checks whether the same seats are still eligible. If they are—which is almost every hand—the pre-shuffled deck promotes straight into play, leaving only a single parallel round-trip of decryption shares to open hole cards. If someone joined, busted, or sat out right before the deal, the table falls back cleanly to an on-demand shuffle and shows a compact progress pill in the top bar.

How the protocol works

You don’t need a cryptography degree to picture what’s happening. Imagine every card in the deck sits inside a transparent lockbox that can hold one padlock from every player at the table—and can only open once every padlock comes off.

  1. Turn all 52 cards into math objects nobody can cheat with. Before a hand begins, every device agrees on the same public mapping from the 52 playing cards to 52 points on an elliptic curve. Nobody gets to pick them, and nobody knows any secret shortcuts between them.
    Under the hood

    We implement Ristretto255 over Curve25519 (RFC 9496)4 from scratch in pure TypeScript and pure Dart—giving a prime-order group with no cofactor edge cases. The 52 cards and 52 Pedersen generators are hashed deterministically onto the curve via Elligator (fromUniformBytes), yielding nothing-up-my-sleeve points M₀ … M₅₁.

  2. Everyone brings a fresh padlock—and proves they hold the key. For each deck, every player invents a one-time secret key on their own device and combines their public padlock into one shared table lock. Crucially, each player must prove they actually know their own secret key—otherwise a cheater could craft a fake padlock specifically shaped to cancel everyone else’s out.
    Under the hood

    Each seat samples a fresh scalar xᵢ, publishes Yᵢ = xᵢ·G with a domain-separated Schnorr proof of possession, and every client verifies all proofs before summing the joint ElGamal public key Y = Σ Yᵢ.

  3. Each player shuffles, re-locks, and attaches an X-ray proof. Starting from the ordered 52-card deck, each player takes a turn scrambling all 52 encrypted cards and adding fresh randomness so nobody can track which card moved where. Alongside their shuffle, they publish a compact zero-knowledge proof (~5 KB) that acts like an X-ray: it proves all 52 original cards are still in the deck—no duplicated aces, no dropped twos—without revealing a single thing about the new order. As long as even one player at the table is honest, the final deck is uniformly random.
    Under the hood

    Each shuffler applies a Fisher–Yates permutation and ElGamal re-encryption (C₁ + rₖ·G, C₂ + rₖ·Y), paired with a Bayer–Groth (2012) NIZK shuffle proof:5 Pedersen vector commitments plus a Schwartz–Zippel product argument over the 52-element permutation.

  4. Peel off every padlock except the owner’s. To deal Alice her two hole cards, every other player at the table removes their padlock from Alice’s two slots and attaches a proof that they unlocked honestly. Alice never sends hers. Left with only her own padlock still on the box, she unlocks her cards locally on her phone or browser—and the server never sees what was inside.
    Under the hood

    For slot p, player i emits decryption share Dᵢ,ₚ = xᵢ·C₁ plus a Fiat–Shamir Chaum–Pedersen proof6 that log_G(Yᵢ) = log_{C₁}(Dᵢ,ₚ). Even after subtracting all n − 1 other shares, the server still sees M + x_Alice·C₁—a standard ElGamal ciphertext under Alice’s private key.

Click through a three-player hand below to watch what the server sees versus what Alice’s device sees at each step—or try tampering with the shuffle to see what happens when someone tries to sneak in an extra ace.

Interactive · 3-Seat Table (Alice, Bob, Carol)
What the server sees (RAM & Wire)
Locked · Alice Locked · Bob Locked · Carol
Waiting to shuffle. Click 1. Jointly shuffle to lock and scramble the 52-card deck under all three keys.
Alice’s device only
?
?
Alice keeps her secret scalar x_Alice in local memory—never sent to the server.

Step 0: Three seats hold independent ephemeral keys. Start the joint shuffle to build an encrypted deck nobody can read.

The server never holds a plaintext deck or unrevealed hole cards—not in memory, and not in its crash-recovery snapshots on disk. Community cards stay locked until betting closes on the prior street, then everyone peels their padlock off the flop, turn, or river in one round-trip. Burn cards are never opened at all.

At showdown, because everyone else’s padlocks on Alice’s hole slots already came off preflop, each surviving contender only needs to publish their own two shares. The proof binds them to the exact cards they were dealt—nobody can swap a losing hand for aces. And if everyone folds before showdown, neither the folder’s nor the winner’s shares are ever published. Those cards stay secret forever unless someone explicitly taps Show cards.

Don’t trust the server to verify itself

There’s an easy trap when implementing mental poker on a client-server architecture: verifying the zero-knowledge proofs on the server and letting the clients trust the server’s broadcasts. If the server operator is in your threat model, server-only verification is theater—a dishonest server could skip the checks, substitute a rigged deck, or ask a client for its own hole-card share on the flop.

In Backroom, every browser and Flutter app verifies the full cryptographic transcript independently: every key proof, every shuffle step starting from the canonical 52-card deck (confirming its own shuffle wasn’t dropped), and every decryption share before trusting a revealed card. Clients also enforce a strict stage-gated share policy—refusing to emit shares for burn slots, future streets while betting is still open, or their own hole cards mid-hand, even if a compromised server asks.

If you open DevTools during a live hand, here is the difference on the wire:

Standard table · room packet
{
  "stage": "preflop",
  "players": [{
    "name": "Alice",
    "cards": [
      { "rank": 14, "suit": "s" },
      { "rank": 13, "suit": "s" }
    ]
  }]
}
Private-Deal · room + sync packets
{
  "stage": "preflop",
  "players": [{
    "name": "Alice",
    "cards": []  // server holds zero cards
  }],
  "slot0": {
    "c1": "7a4e19c0…b831",
    "c2": "c91f04a2…62ef"
  }
}
Backroom Private-Deal Hold’em table showing the green Private Deal verification popover with Ristretto255, Bayer-Groth, and Chaum-Pedersen status, 2 of 2 proofs checked, next hand deck pre-shuffled and ready, and 31 ms deal turnaround.
Backroom’s live verification sheet during a hand: both shuffle proofs verified locally, the next hand’s deck already pre-shuffled in the background, and a 31 ms deal turnaround.

How fast is pure BigInt cryptography?

My first naive Ristretto255 implementation in JavaScript took ~131 ms per shuffle because re-encrypting 52 cards meant running 104 separate curve multiplications from scratch. Two standard speedups cut that down dramatically: precomputing a small lookup table of multiples of G and Y (skipping all the repeated point doublings), and batching the proof’s 52 curve terms together with Pippenger’s bucket method7—still in pure, readable TypeScript and Dart with zero native addons or WASM toolchains.

Benchmark Environment Time
52-card shuffle + zero-knowledge proof Web / Node.js (pure JS BigInt) 88 ms (verify 73 ms)
52-card shuffle + zero-knowledge proof Flutter / Dart VM (M-series) 165 ms (verify 136 ms)
Pre-prepared deal turnaround (1 round-trip) Backroom live Socket.IO (2-player) 18 ms (full hand #2: 172 ms)
Sequential mental poker baseline Dominion mainnet (74-hand median) 4,700 ms

Because the background shuffle finishes in well under a second while the previous hand is still playing, the extra wait on top of Backroom’s normal 1.5-second fold cadence is barely noticeable—under two hundred milliseconds end-to-end.

Edge cases and the honest trust boundary

Real-time privacy with n-of-n decryption isn’t free. It changes what happens when someone refreshes or drops offline, and it’s worth being upfront about every tradeoff:

  • Page refreshes and brief drops. Ephemeral per-deck keys stay in sessionStorage (capped to the last eight decks per table), so reloading mid-hand seamlessly recovers your key, re-decrypts your hole cards, and keeps answering board and showdown share requests.
  • Showdown griefing. If a losing contender refuses to publish their own showdown shares before the 15-second reveal deadline, they forfeit showdown (Mucked — no reveal) and honest contenders still win the pot.
  • Offline seats and mid-hand disconnects. Under n-of-n decryption, a table mathematically cannot open the next board card without every seat’s share—and you can’t let a losing player dodge a pot just by closing their tab. Two rules handle it without ever escrowing keys on the server: the moment a player folds, their device proactively publishes its decryption shares for the five community-card slots (never their own hole cards), so folded seats can drop offline without stalling the flop, turn, or river; and if a live contender disconnects and blocks a street or runout reveal past the 15-second deadline, they forfeit their bet and get sat out—awarding the pot outright in a two-way hand, or splitting their forfeited chips among the remaining honest contenders in a multiway pot.

There is one boundary cryptography alone cannot close: how players get the client code.

Mental poker guarantees that someone who controls only the game server, its memory, its proxy, and its database cannot read your unrevealed hole cards. If that same operator can silently serve modified JavaScript to your browser on the next page load, the modified client could simply exfiltrate your cards after decrypting them locally. Closing that last mile requires independently reviewable, reproducibly signed client builds—like signed native Flutter releases whose build keys sit outside the game server—plus an independent cryptographic audit before making hard security promises.

Still, the first time I sat down with friends on a Private-Deal table—watching the next hand deal on Backroom’s normal 1.5-second rhythm while my own server had literally zero idea what anyone was holding—something clicked. Good poker tables run on trust, sure. It’s even nicer when the table doesn’t have to ask for it.

Right now, Private-Deal is an opt-in switch while we put a brand-new protocol through real games and shake out every edge case. Long term, though, there’s no good reason for “normal” tables and “private” tables to exist as two separate modes. Once this has enough hands under its belt, Backroom will rotate every table onto Private-Deal by default—so you don’t have to remember to turn privacy on.

Try it with your table. Backroom is completely free to use—no accounts, no rake, no ads. Create a Hold’em table, switch on Private-Deal, share the link with your friends, and open DevTools if you want to watch the encrypted deck move for yourself.

Start a free Backroom table