Verifiable Randomness Documentation

Verifiable Randomness Systems

View the Project on GitHub blockrand-api/blockrand-js

Random Sampling Without Replacement

The Problem

Many systems need to select multiple unique outcomes from a set.

Examples:

A common mistake is repeatedly drawing random values and re-rolling duplicates.

This approach:

When real value is involved, the selection must be:

What Is Sampling Without Replacement?

Sampling without replacement means:

If we pick 3 winners from:

[A, B, C, D, E]

Possible result:

[B, E, A]

Invalid result:

[B, E, B]

Why Naive Re-Rolling Is Dangerous

Typical implementation:

  1. Pick random index
  2. If already chosen → reroll

Problems:

Hidden Bias

Earlier items have higher chance of being selected. Distribution becomes uneven as duplicates increase.

Performance Degrades

If selecting many winners:

Hard to Verify

External auditors cannot reproduce:

This breaks provable fairness.

Correct Approach: Fisher–Yates Based Selection

The standard unbiased method:

  1. Start with full list
  2. Shuffle deterministically
  3. Take first K elements

This guarantees:

Deterministic Shuffle Requirement

For verifiable systems, shuffle must be driven by:

Each swap decision is derived from a hash.

This ensures:

Algorithm Outline

Given:

Steps:

  1. Generate deterministic random values
  2. Perform Fisher–Yates shuffle
  3. Output first K entries

Time complexity: O(N)
No retries required.

Alternative: Index Mapping Method

When N is very large (millions):

This simulates Fisher–Yates without full memory cost.

Used in:

Why Order Matters

In auditable systems, the entire shuffled order must be reproducible.

Reasons:

Storing only final winners is insufficient.

Common Engineering Mistakes

Using Modulo on Indices

If range mapping is biased:

Always use rejection sampling for index generation.

Mixing Multiple Random Sources

Combining:

Breaks deterministic replay. Use a single entropy pipeline.

Mutating Lists Differently Across Platforms

Different languages may:

This causes verification mismatches. Use canonical ordering rules.

Deterministic Audit Pattern

Inputs:

Process:

  1. Hash inputs
  2. Generate unbiased indices
  3. Execute Fisher–Yates swaps
  4. Produce final ordered list

Output:

Anyone can independently verify.

Real-World Use Cases

Raffles & Giveaways

Selecting:

Requires provable absence of duplicates.

NFT & Token Launches

Allowlist selection must be:

Tournament Seeding

Bracket fairness depends on unbiased ordering.

Loot Systems With Unique Drops

Ensures:

Why This Matters for Trust

Duplicate winners or biased draws lead to:

Most fairness disputes are caused by:

Key Takeaway

Sampling without replacement is not repeated random picking.

The correct method is:

This guarantees: