Skip to content
Entropy Estimation
step 1/5

Reading — step 1 of 5

Read

~1 min readEntropy Sources

Entropy Estimation

How many BITS of entropy is in a sample? Shannon entropy:

H(X) = -sum_i p(x_i) * log2(p(x_i))

For 8 random bits (uniform): H = 8 bits/byte (perfect). For "abcdef..." (all letters): H ≈ log2(26) ≈ 4.7 bits per char (less because alphabet is smaller). For text: H ≈ 4-5 bits/byte (English has redundancy).

Linux maintains a "pool entropy estimate". Each interrupt, mouse move, etc. adds a few bits. The estimate is conservative — typically much less than the actual unpredictability.

How many entropy bits do you NEED?

  • 128 bits: cryptographically strong (2^128 brute force is currently infeasible)
  • 256 bits: paranoid; future-proof against advances

For a 256-bit AES key: collect 256 bits of true entropy → seed CSPRNG → CSPRNG outputs the key.

Common bug: mistaking RANDOM-LOOKING for RANDOM. Compressed data, encrypted data, hashes look random but provide no entropy if the input is predictable.

Good test: NIST SP 800-22 statistical tests. Or TestU01. They detect patterns invisible to the eye.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…