Provably Fair System
Our lottery system uses Bitcoin blockchain data to ensure complete transparency and fairness. Every draw is verifiable, unpredictable, and completely transparent.
How Our Fairness System Works
We use the Bitcoin blockchain as a source of randomness for our lottery draws. This ensures that the results are completely fair and verifiable by anyone.
Key Principle
We use the hashes of Bitcoin blocks that are mined AFTER the lottery ends. This makes it impossible for anyone to predict or manipulate the results.
The Draw Process
Our algorithm follows a precise 6-step process to ensure complete fairness
End of lottery
Timestamp recorded
Wait for blocks
3 Bitcoin blocks mined
Hash retrieval
Get block hashes
Combination
Join with ':'
SHA-256
Hash calculation
Fair modulo
Winner selection
Interactive Demo
Try our fairness algorithm with real Bitcoin block data and see how it works in practice
Choose Demo Mode:
Select a Lottery
Select a lottery to see details
Manual Parameters
Results
Source Code
Copy this code to test our fairness algorithm locally:
import { createHash } from 'crypto';
const TICKETS_AMOUNT = 5000;
const BLOCK_HASHES = [
'000000000000000000abcd1234ef567890abcdef1234567890abcdef1234567890',
'000000000000000000bcde2345ef678901abcdef1234567890abcdef1234567890',
'000000000000000000cdef3456ef789012abcdef1234567890abcdef1234567890'
];
/**
* Combine block hashes using a clear separator to avoid any ambiguity.
*
* @param {string[]} hashes - Array of block hashes.
* @returns {string} Combined hash string.
*/
function combineBlockHashes(hashes) {
return hashes.join(':');
}
/**
* Generate a SHA-256 hash from the combined block hashes and return it as a BigInt.
*
* @returns {BigInt} The BigInt representation of the SHA-256 hash.
*/
function getFinalHashBigInt() {
const combinedHash = combineBlockHashes(BLOCK_HASHES);
const hashBuffer = createHash('sha256').update(combinedHash).digest();
return BigInt('0x' + hashBuffer.toString('hex'));
}
/**
* Generate a random ticket number between 1 and TICKETS_AMOUNT (inclusive)
* using rejection sampling to eliminate any modulo bias.
*
* @returns {number} The winning ticket number.
*/
function getRandomTicketNumber() {
const maxValue = BigInt(2) ** BigInt(256); // Maximum possible value for a 256-bit hash.
let candidate = getFinalHashBigInt();
// Define the limit to eliminate modulo bias:
// Only values strictly below 'limit' are accepted.
const limit = maxValue - (maxValue % BigInt(TICKETS_AMOUNT));
// Rejection sampling: rehash if candidate is in the biased zone.
while (candidate >= limit) {
// Rehash candidate to generate a new candidate.
const candidateBuffer = Buffer.from(candidate.toString(16).padStart(64, '0'), 'hex');
candidate = BigInt('0x' + createHash('sha256').update(candidateBuffer).digest('hex'));
}
// Map candidate uniformly to [1, TICKETS_AMOUNT]
return Number(candidate % BigInt(TICKETS_AMOUNT)) + 1;
}
const winningTicketNumber = getRandomTicketNumber();
console.log(`Winning Ticket Number: ${winningTicketNumber}`);
How to use:
- Save the code as
fairness-test.js
- Run with Node.js:
node fairness-test.js
- Modify
TICKETS_AMOUNT
andBLOCK_HASHES
to test different scenarios
Independent Verification
You can verify any draw by following these simple steps using public blockchain data
Verification Example
For lottery #123 ended on 2024-01-15 at 14:30:00 UTC:
hash1:hash2:hash3
Why It's Fair
Multiple layers of transparency and verification ensure complete fairness
Unpredictability
Bitcoin block hashes are generated by thousands of independent miners worldwide. It is impossible to predict or influence these values.
Timing
The blocks used are mined AFTER the lottery ends, ensuring that no manipulation is possible during ticket sales.
Public Data
All data used (block hashes, timestamps) is publicly available on the Bitcoin blockchain.
Determinism
With the same input data, the algorithm always produces the same result, allowing complete verification.
Audit and Transparency
Our commitment to transparency includes multiple layers of verification and public accountability
Transparent Algorithm
Our lottery draw algorithm is publicly verifiable for complete transparency
Public API
All lottery data is accessible via our public API
Blockchain Verification
Every draw can be independently verified using blockchain data
Regular Audits
Third-party security audits ensure ongoing compliance