Protocol engineers building fair launches, lotteries, and shuffles
Fair-launch randomness
Uniform, unmanipulable randomness with no trusted oracle.
Multiple parties commit to random seeds, then reveal them. The final randomness is a hash of all revealed seeds. As long as one participant is honest and unpredictable, the result is uniform and no single party can steer it.
The problem
Any on-chain randomness that one party can compute in advance is a party they can bias. A commit-reveal round makes each contributor lock in their seed before anyone sees the others, so no one can adaptively choose a seed to fix the outcome.
How commit-reveal does it
- 01 Each participant commits to a random seed: commitment_i = H(seed_i ‖ salt_i).
- 02 Once all commitments are in, participants reveal their seeds and salts.
- 03 The library verifies each reveal against its commitment; unrevealed or mismatched seeds are dropped per protocol policy.
- 04 Combine the verified seeds — e.g. SHA-256 over the concatenation — to produce the shared randomness.
The code
scheme = CommitRevealScheme()
commitment, salt = scheme.commit(my_seed) # commit your seed
# ... collect everyone's commitments, then reveal ...
assert scheme.reveal(my_seed, salt, commitment)
final_randomness = sha256(b"".join(all_revealed_seeds)).digest() More use cases
Anti-MEV & fair ordering
Front-runners cannot react to orders they cannot yet see.
Verifiable on-chain AI
Independent agents answer without copying each other.
Sealed-bid auctions
No bidder can peek at another’s bid before the deadline.
Hidden ballots & market resolution
Vote or resolve in secret, prove the reveal is honest.
Teaching cryptography
A readable, zero-dependency reference you can teach from.