Provably Fair Randomness
Trust in a decentralized jackpot protocol relies entirely on the integrity of its random number generation. QanVault implements a cryptographically auditable Commit-Reveal scheme that guarantees results cannot be manipulated, predicted, or backdated by anyone, including the protocol operators.
What Does Provably Fair Mean?#
A game or draw is provably fair when any independent player or auditor can verify with mathematical certainty that:
- The winning numbers were generated from unalterable randomness.
- The operator did not know the winning ticket ID before ticket purchases closed.
- The winner selection algorithm followed deterministic mathematical rules.
- No tickets were retroactively added or removed after the draw cutoff.
The Commit-Reveal Architecture#
To prevent frontrunning and seed manipulation, QanVault executes winner selection across two cryptographic phases:
Draw Closes & Hash Submitted
Keeper generates secret entropy S and computes commitment H = keccak256(S, drawId, blockHash). Purchases for drawId freeze.
Cryptographic Seed Verification
Keeper publishes S on-chain. Contract verifies keccak256(S, drawId, blockHash) == H. Cannot be manipulated post-commitment.
Modulo Winner Derivation
Winning Ticket = StartTicket + (Entropy % TotalTickets). Owner identified via O(log B) binary search across ticket batches.
Mathematical Definitions
- Commitment Phase:
The commitment H is stored immutably in the contract state before any random reveal can occur.
- Reveal Phase:
When the secret seed is published, the smart contract validates:
- Combined Entropy Derivation:
By incorporating the block hash of the commitment block, the final entropy is tied to decentralized blockchain consensus, ensuring neither the keeper nor miners can single-handedly force a specific outcome.
Sampling Without Replacement#
When a draw awards multiple prize tiers (e.g., 1st, 2nd, and 3rd place), winners must be distinct:
- The first winning ticket W_1 is derived:
- If W_2 = \text{Entropy}_1 \pmod{\text{Total Tickets}} belongs to the same wallet or ticket ID as W_1, the contract derives the next pseudo-random candidate using continuous hashing:
- Sampling continues until all prize slots are occupied by distinct winning entries.
Cryptographic Roadmap: Post-Quantum VRF#
QanVault's randomness architecture is fully modular via the IRandomnessProvider interface:
interface IRandomnessProvider {
function requestRandomness(uint256 drawId) external returns (bytes32 requestId);
function fulfillRandomness(uint256 drawId, bytes32 seed) external;
function getEntropy(uint256 drawId) external view returns (uint256 entropy, bool fulfilled);
}- Current Mainnet Implementation: Chainlink VRF v2.5 / Commit-Reveal oracle integration.
- QAN Platform Consensus VRF: Future-proofed to transition to QAN Platform's native post-quantum lattice-based verifiable random function (CRYSTALS-Dilithium) as QAN mainnet activates.
How to Verify Any Draw Independently#
You do not need to rely on the QanVault user interface to verify that a draw was fair. You can verify it directly in your terminal:
# 1. Fetch the commitment hash and revealed seed from BscScan or RPC
DRAW_ID=104
COMMIT_BLOCK=38492015
REVEALED_SEED="0xa8f2..."
BLOCK_HASH="0x4b7e..."
# 2. Compute local keccak256 hash using foundry cast or python
cast keccak $(cast concat-hex $REVEALED_SEED $(cast to-hex $DRAW_ID) $(cast to-hex $COMMIT_BLOCK))If the generated hash matches the on-chain commitment hash recorded at draw closure, the draw is cryptographically proven to be valid and unmanipulated.
Next Steps#
- How winners claim their funds: Prize Claims & Rollover
- Complete security audit details: Security & Invariants