RNG Crypto Specialist
Use this skill to make RNG behavior reproducible, tamper-evident, and independently verifiable.
Workflow
- Define fairness contract before implementation.
- Specify game outcomes that are RNG-derived, transcript fields, and reveal timing.
- Set immutable rules for server seed rotation, client seed changes, and nonce increments.
- Declare what players can verify pre- and post-reveal.
- Choose cryptographic primitives and transcript schema.
- Prefer
SHA-256 commitments and HMAC-SHA256 outcome derivation unless the system requires otherwise.
- Store canonical transcript fields:
serverSeedHash, serverSeed (after reveal), clientSeed, nonce, gameId, mode, and outcome.
- Define exact string/byte serialization and encoding rules to avoid replay mismatches.
- Enforce bias-free outcome mapping.
- Derive randomness from deterministic crypto material only.
- Convert random integers to bounded outcome ranges with rejection sampling.
- Reject modulo-only mapping when
2^n is not evenly divisible by range size.
- Implement seed and nonce lifecycle controls.
- Treat server seed as secret until reveal, then rotate immediately after reveal window.
- Keep per-session or per-player nonce monotonic and gap-free.
- Block replay or out-of-order nonce acceptance at API boundaries.
- Verify transcripts with deterministic tooling.
- Recompute commitment hashes from revealed server seeds.
- Recompute expected outcomes from
serverSeed, clientSeed, and nonce.
- Treat hash mismatches, nonce reuse, or outcome mismatches as hard blockers.
- Produce cryptographic sign-off package.
- Deliver algorithm specification, sample transcripts, verification command outputs, and open risks.
- Include exact patch plan with file paths for any fixes.
Commands
python3 scripts/verify_provably_fair.py \
--server-seed "<secret>" \
--client-seed "<client>" \
--nonce 0 \
--range-max 10000
python3 scripts/verify_provably_fair.py \
--input <transcript.jsonl> \
--default-range-max 10000
Treat non-zero exits as blocker findings.
Output Contract
When handling RNG crypto tasks, return:
Protocol Summary: commit-reveal flow, primitives, serialization, and rotation policy.
Verification Findings: pass/fail for commitments, outcomes, nonce monotonicity, and bias handling.
Patch Plan: exact files/functions to change and why.
Evidence: commands run and key outputs.
Residual Risks: unresolved issues preventing sign-off.
References
references/workflow.md: end-to-end implementation and audit procedure.
references/crypto-primitives.md: approved primitives, mappings, and pitfalls.
references/signoff-template.md: concise report structure for handoff.
Execution Rules
- Keep pre-reveal server seeds confidential; never log plaintext secrets in production traces.
- Freeze canonical serialization and test vectors before cross-language implementation.
- Require rejection sampling for bounded integer mapping unless divisibility is guaranteed.
- Mark any unverifiable outcome path as non-compliant.
1---2name: rng-crypto-specialist3description: Design, implement, and audit provably fair RNG and cryptographic seed workflows for casino games. Use when defining commit-reveal architecture, server/client seed lifecycle, nonce progression, hash/HMAC outcome derivation, bias-free range mapping, fairness transcript verification, or cryptographic release sign-off evidence.4---56# RNG Crypto Specialist78Use this skill to make RNG behavior reproducible, tamper-evident, and independently verifiable.910## Workflow11121. Define fairness contract before implementation.13- Specify game outcomes that are RNG-derived, transcript fields, and reveal timing.14- Set immutable rules for server seed rotation, client seed changes, and nonce increments.15- Declare what players can verify pre- and post-reveal.16172. Choose cryptographic primitives and transcript schema.18- Prefer `SHA-256` commitments and `HMAC-SHA256` outcome derivation unless the system requires otherwise.19- Store canonical transcript fields: `serverSeedHash`, `serverSeed` (after reveal), `clientSeed`, `nonce`, `gameId`, `mode`, and `outcome`.20- Define exact string/byte serialization and encoding rules to avoid replay mismatches.21223. Enforce bias-free outcome mapping.23- Derive randomness from deterministic crypto material only.24- Convert random integers to bounded outcome ranges with rejection sampling.25- Reject modulo-only mapping when `2^n` is not evenly divisible by range size.26274. Implement seed and nonce lifecycle controls.28- Treat server seed as secret until reveal, then rotate immediately after reveal window.29- Keep per-session or per-player nonce monotonic and gap-free.30- Block replay or out-of-order nonce acceptance at API boundaries.31325. Verify transcripts with deterministic tooling.33- Recompute commitment hashes from revealed server seeds.34- Recompute expected outcomes from `serverSeed`, `clientSeed`, and `nonce`.35- Treat hash mismatches, nonce reuse, or outcome mismatches as hard blockers.36376. Produce cryptographic sign-off package.38- Deliver algorithm specification, sample transcripts, verification command outputs, and open risks.39- Include exact patch plan with file paths for any fixes.4041## Commands4243```bash44python3 scripts/verify_provably_fair.py \45 --server-seed "<secret>" \46 --client-seed "<client>" \47 --nonce 0 \48 --range-max 100004950python3 scripts/verify_provably_fair.py \51 --input <transcript.jsonl> \52 --default-range-max 1000053```5455Treat non-zero exits as blocker findings.5657## Output Contract5859When handling RNG crypto tasks, return:60611. `Protocol Summary`: commit-reveal flow, primitives, serialization, and rotation policy.622. `Verification Findings`: pass/fail for commitments, outcomes, nonce monotonicity, and bias handling.633. `Patch Plan`: exact files/functions to change and why.644. `Evidence`: commands run and key outputs.655. `Residual Risks`: unresolved issues preventing sign-off.6667## References6869- `references/workflow.md`: end-to-end implementation and audit procedure.70- `references/crypto-primitives.md`: approved primitives, mappings, and pitfalls.71- `references/signoff-template.md`: concise report structure for handoff.7273## Execution Rules7475- Keep pre-reveal server seeds confidential; never log plaintext secrets in production traces.76- Freeze canonical serialization and test vectors before cross-language implementation.77- Require rejection sampling for bounded integer mapping unless divisibility is guaranteed.78- Mark any unverifiable outcome path as non-compliant.