liveBook · Manning

Uniform distribution

As explained in Hacking Cryptography

A uniform distribution assigns equal probability density or probability mass across the possible outcomes of a random variable.

A uniform distribution gives every possible outcome the same probability mass or density. For random-number generators, uniform output makes each candidate equally difficult to guess; even small biases can reduce the attacker’s search space. section 2.0 section 2.1

Biased choices shrink the search space

A date-formatted password appears to offer 100 million eight-digit combinations, but restricting it to valid months, days, and the previous 150 years leaves 12 × 31 × 150 = 55,800 possibilities. Biases therefore make guessing substantially easier. section 2.1.1

Uniformity also maximizes uncertainty, or entropy. For a binary outcome, entropy is H(X) = −Σ pₓ log₂ pₓ; a fair coin reaches 1 bit, while probabilities of 0.75/0.25 and 0.80/0.20 produce lower values. section 2.1.2

Apply the idea defensively:

  • Use uniformly distributed random values when generating cryptographic keys, salts, or randomized ballots. section 2.1.1
  • Treat deviations from uniformity as a security problem because they make likely outputs easier to guess. section 2.1
Equation 2.2
\[\begin{aligned} H(X) &= -\sum_{x \in X} p_x \log_2 p_x \notag\\ &= - p_{1} \times \log_2 (p_{1}) - p_{2} \times \log_2 (p_{2}) - ... p_{n} \times \log_2 (p_{n}) \label{equation:entropy-binary-log} \end{aligned}\]

Use the entropy equation to quantify how probability imbalance reduces uncertainty. section 2.1.2

How Hacking Cryptography covers it

How deep it goes
Explains equal likelihood, guessing resistance, search-space reduction, and entropy with equations and executable Go examples.
Examples
Uses human number selection, date-formatted passwords, random keys, randomized ballots, and biased coin-toss probabilities.
What you can do after
Evaluate RNG unpredictability by recognizing bias, estimating search-space reduction, and calculating entropy from outcome probabilities.
How it connects
Connects uniform distribution to random number generators, entropy, cryptographic keys, passwords, and cryptography.

Also explained in

Compare how 9 books explain uniform distribution →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Hacking Cryptography. The section links point to the parts of the book it draws on.