Overview
The provably fair seed endpoints allow users to retrieve and rotate their cryptographic seeds used in the provably fair system. These seeds ensure that game outcomes are deterministic and verifiable.Get Current Seeds
Authentication
This endpoint requires authentication. Include a valid Supabase session token.
Response
SHA-256 hash of the current server seed. This allows verification without revealing the seed.
The current client seed. This is visible to the user and can be customized.
Current nonce value. Increments with each game round to ensure unique outcomes.
Example Response
Error Responses
User is not authenticated
Database error occurred while creating or fetching seeds
Implementation Details
If the user doesn’t have existing seeds, the endpoint automatically creates initial seeds:- Generates a random server seed
- Generates a random client seed
- Sets nonce to 0
source/app/api/provably-fair/seed/route.ts:5
cURL Example
Rotate Seeds
Authentication
This endpoint requires authentication. Include a valid Supabase session token.
Request Body
Optional custom client seed. If not provided, a random client seed will be generated.
Example Request
Response
SHA-256 hash of the new server seed
The new client seed (custom or auto-generated)
Reset to 0 after seed rotation
Example Response
Error Responses
User is not authenticated
Database error occurred during seed rotation
Implementation Details
When seeds are rotated:- New Server Seed: A cryptographically secure random server seed is generated
- New Client Seed: Either uses the provided client seed or generates a new random one
- Nonce Reset: Nonce is reset to 0
- Timestamp Update: Records the rotation time in
updated_at
The old server seed should be revealed to the user after rotation, allowing them to verify all previous game results. This is a critical part of the provably fair system.
source/app/api/provably-fair/seed/route.ts:48
cURL Example
Best Practices
When to Rotate Seeds
Regular Rotation
Rotate seeds periodically (e.g., every 100 games) to maintain trust
User Request
Allow users to rotate seeds at any time for full transparency
After Verification
Rotate after revealing the old server seed for verification
Suspicious Activity
Rotate if there’s any concern about seed compromise
Seed Management Tips
Verification Workflow
- Before Playing: User retrieves
server_seed_hashvia GET endpoint - During Play: Each game uses the current seeds + incrementing nonce
- Seed Rotation: User calls POST endpoint to rotate seeds
- Reveal Old Seed: System reveals the previous
server_seed - Verification: User confirms
SHA256(server_seed)matches stored hash - Recalculation: User recalculates all roll results using revealed seed
Security Considerations
Database Schema
Theuser_seeds table structure:
