1. The outcome lifecycle
Every /api/floats, /api/ints, /api/dice, or /api/shuffle call walks the same path. The diagram below traces a single outcome from the moment you pick a clientSeed to the moment it lands inside a publicly published daily Merkle root.
2. HMAC-SHA256 client-seed mixing
Random bytes come from HMAC-SHA256 keyed by our secret serverSeed over the message clientSeed:nonce:round (incrementing round for each 32-byte block).
- Unbiased mapping: floats take 4 bytes each; integers take 4 bytes and reject out-of-range values so every integer is equally likely.
- Two-sided fairness: the secret server seed stops callers from grinding
clientSeedvalues, while the pre-published hash stops us from changingserverSeedafter seeing yours.
How to verify it yourself. After an outcome, save the clientSeed and serverHash. Once we reveal the serverSeed (via the dashboard, the commit-reveal flow, or in any inclusion proof), confirm SHA256(serverSeed) === serverHash, then recompute HMAC-SHA256(serverSeed, "clientSeed:nonce:round") using the reference library:
npm install @provableio/provable-core
# then in Node:
const { Provable } = require("@provableio/provable-core");
const out = Provable(() => {})({ clientSeed, serverSeed, nonce }).floats(5);
3. Commit-reveal for stronger fairness
The one-shot endpoints publish a serverHash with every response — that is already a binding commitment, because we hand you the hash on the first call for a given client seed and can never silently change it afterward. For maximum-paranoia use cases (lotteries, raffles, on-chain settlement) we also expose an explicit two-step flow:
POST /api/commit— we generate a freshserverSeed, return itsSHA-256hash and acommitId, and lock that pair for up toCOMMIT_TTL_MS(10 minutes by default).POST /api/reveal— you pass thecommitIdplus yourclientSeed. We reveal the serverSeed, proveSHA256(serverSeed) === serverHash, and only then mix in your seed to produce the outcome.
This rules out the only remaining attack on the one-shot flow — a malicious server picking a serverSeed in response to a clientSeed it has already seen. The commit happens before the client seed exists.
4. Daily Merkle transparency roots
Every UTC night we hash every outcome from the previous day into a SHA-256 Merkle tree and publish the root at /transparency. The leaf encoding is fixed and documented:
- Leaf:
SHA256(0x00 || utf8("clientSeed:cursor:nonce|serverHash|clientSeed|timestampMs")) - Internal node:
SHA256(0x01 || left(32) || right(32)) - Odd level: last node is duplicated (Bitcoin-style).
The root for any past day is append-only: a single byte changed in any past outcome would shift the root and break every inclusion proof for that day. Anyone can fetch GET /api/merkle/:date for the root and GET /api/merkle/:date/proof/:outcomeId for an inclusion proof, then recompute the root in their own browser or script using only the leaf and the published siblings — no trust in our server required.
The verifier on /transparency does exactly that, in your browser, using the WebCrypto API.
5. Idempotency keys
Send an optional Idempotency-Key header to safely retry requests over flaky networks and receive byte-identical results without consuming a second draw:
- 24-hour replay cache: stored by
(scope, key); matching retries return the cached response withIdempotent-Replayed: true. - Mismatch guard: reusing a key with different parameters returns
409instead of silently drawing something else. - Single-flight concurrency: concurrent retries with the same key are serialized via a database sentinel row so only one outcome is created.
6. Signed webhooks
When you wire a webhook to your account, every delivery carries an X-Provable-Signature: t=<unix>,sha256=<hex> header. The signature is HMAC-SHA256(webhook_secret, t + "." + raw_request_body), so the send time can't be altered. Verify it with a constant-time comparison and reject stale timestamps, which stops replays:
// Node.js
const crypto = require("crypto");
const sig = Object.fromEntries(
req.get("X-Provable-Signature").split(",").map((p) => p.split("=")));
const expected = crypto.createHmac("sha256", WEBHOOK_SECRET)
.update(`${sig.t}.`).update(rawBody).digest("hex");
const ok = expected.length === (sig.sha256 || "").length
&& crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(sig.sha256))
&& Math.abs(Date.now() / 1000 - Number(sig.t)) <= 300;
Webhook URLs are validated for SSRF before each delivery: private IP ranges, link-local addresses, and .local/.internal hostnames are blocked. Failed deliveries are retried with exponential backoff and surfaced in your dashboard's delivery history.
7. Operational hygiene
- Open source core. The cryptographic primitives live in provable-core on GitHub. The same library runs server-side and is shipped to verifiers.
- HTTPS-only. The production API and dashboard are TLS-terminated; HTTP redirects to HTTPS.
- Session cookies.
HttpOnly,SameSite=Lax, andSecurein production. CSRF tokens are required on every state-changing request from the dashboard. - API keys. Stored hashed in Postgres; only the prefix and a masked preview are ever returned after creation. Keys can be rotated or revoked from the dashboard at any time, with per-key IP and Referer allowlists.
- Test keys.
pk_test_*keys produce deterministic outcomes that never touch live seed state, never count against quota, and never fire webhooks — safe for fixtures, CI, and snapshots.
8. Responsible disclosure
If you find a security issue, please email [email protected] with reproduction steps. We will acknowledge receipt within two business days and keep you in the loop while we fix and disclose. Please do not publicly disclose before we have had a reasonable chance to patch.
Verify a specific outcome → · Browse daily Merkle roots → · Who runs this →