The Fishcake🐶🐾 on Nostr: Some info about entropy, now sure how well it’ll render here: Entropy is one of ...
Some info about entropy, now sure how well it’ll render here:
Entropy is one of those cryptography topics where the deceptively simple definition—“randomness”—causes a lot of bad implementations.
The key distinction is:
Entropy is a property of a probability distribution, not of a string.
If you generate a 256-bit key uniformly with a cryptographically secure RNG, it has 256 bits of min-entropy. If you generate 256 bits from a broken RNG that only has 40 bits of unpredictability, you don’t magically have a 256-bit key because the output happens to be 256 bits long.
For practical cryptography, I’d break the topic into:
1. Shannon entropy
H(X)=-\sum_x p(x)\log_2p(x)
Useful for information theory, but often not the right measure for cryptographic security.
2. Min-entropy
H_\infty(X)=-\log_2(\max_x p(x))
This is much more relevant to cryptography because it measures the probability of the most likely guess.
3. Guessing entropy / guesswork
Instead of asking how much information exists, ask how many guesses an attacker needs on average or in the worst case.
4. Conditional entropy
This is where things become particularly important:
H_\infty(X\mid E)
How much unpredictability remains after the attacker knows everything they can observe.
5. Entropy extraction
You can take a noisy/high-entropy-but-biased source and use a cryptographic extractor or randomness extractor to produce nearly uniform bits.
This is fundamentally different from simply hashing something and saying “SHA-256 makes it random.”
6. CSPRNGs / DRBGs
Normally you don’t continuously collect “perfect entropy” for every cryptographic operation. You seed a secure generator from an operating-system entropy source and then safely expand that seed into enormous amounts of pseudorandom data.
7. The entropy bottleneck
This is the fun part.
Suppose you have:
256 bits output
↑
SHA-256
↑
64 bits actual entropy
↑
noisy hardware source
You have 64 bits of security, not 256.
Conversely:
256 bits true entropy
↓
SHA-256
↓
256-bit uniformly distributed key
Now the extraction/compression is sensible.
A particularly nasty misconception
People often say:
“I generated a 32-byte random value, therefore I have 256 bits of entropy.”
That’s only true if those 32 bytes are actually sampled uniformly from 2^{256} possibilities.
For example, suppose your “random” 32-byte value is:
random_device() % 1000000
encoded into 32 bytes.
It looks like 256 bits.
It contains only about:
\log_2(1,000,000)\approx19.9
bits of entropy.
An attacker can enumerate the entire space in ~1 million attempts.
And there’s an even nastier issue
Entropy doesn’t automatically accumulate just because you collect independent-looking data.
If you have sources A and B:
H(A,B)=H(A)+H(B\mid A)
not necessarily:
H(A)+H(B)
If B is completely determined by A, then:
H(B\mid A)=0
So concatenating:
timestamp
process ID
memory address
CPU counter
UUID
doesn’t give you the sum of their apparent bit widths.
That’s why modern cryptographic systems generally prefer:
OS CSPRNG → cryptographic primitive → key
rather than trying to invent an entropy-collection system themselves.
Published at
2026-08-15 08:30:58 UTCEvent JSON
{
"id": "eef71f5a2fc192edf17eb95aed55771093dbf5d828dfe63de09959469ba91985",
"pubkey": "8fb140b4e8ddef97ce4b821d247278a1a4353362623f64021484b372f948000c",
"created_at": 1786782658,
"kind": 1,
"tags": [
[
"client",
"Primal iOS"
]
],
"content": "Some info about entropy, now sure how well it’ll render here:\n\nEntropy is one of those cryptography topics where the deceptively simple definition—“randomness”—causes a lot of bad implementations.\n\nThe key distinction is:\n\nEntropy is a property of a probability distribution, not of a string.\n\nIf you generate a 256-bit key uniformly with a cryptographically secure RNG, it has 256 bits of min-entropy. If you generate 256 bits from a broken RNG that only has 40 bits of unpredictability, you don’t magically have a 256-bit key because the output happens to be 256 bits long.\n\nFor practical cryptography, I’d break the topic into:\n\n1. Shannon entropy\n H(X)=-\\sum_x p(x)\\log_2p(x)\n Useful for information theory, but often not the right measure for cryptographic security.\n2. Min-entropy\n H_\\infty(X)=-\\log_2(\\max_x p(x))\n This is much more relevant to cryptography because it measures the probability of the most likely guess.\n3. Guessing entropy / guesswork\n Instead of asking how much information exists, ask how many guesses an attacker needs on average or in the worst case.\n4. Conditional entropy\n This is where things become particularly important:\n H_\\infty(X\\mid E)\n How much unpredictability remains after the attacker knows everything they can observe.\n5. Entropy extraction\n You can take a noisy/high-entropy-but-biased source and use a cryptographic extractor or randomness extractor to produce nearly uniform bits.\n This is fundamentally different from simply hashing something and saying “SHA-256 makes it random.”\n6. CSPRNGs / DRBGs\n Normally you don’t continuously collect “perfect entropy” for every cryptographic operation. You seed a secure generator from an operating-system entropy source and then safely expand that seed into enormous amounts of pseudorandom data.\n7. The entropy bottleneck\n This is the fun part.\n Suppose you have:\n\n256 bits output\n↑\nSHA-256\n↑\n64 bits actual entropy\n↑\nnoisy hardware source\n\n You have 64 bits of security, not 256.\n Conversely:\n\n256 bits true entropy\n↓\nSHA-256\n↓\n256-bit uniformly distributed key\n\n Now the extraction/compression is sensible.\n\nA particularly nasty misconception\n\nPeople often say:\n\n“I generated a 32-byte random value, therefore I have 256 bits of entropy.”\n\nThat’s only true if those 32 bytes are actually sampled uniformly from 2^{256} possibilities.\n\nFor example, suppose your “random” 32-byte value is:\n\nrandom_device() % 1000000\n\nencoded into 32 bytes.\n\nIt looks like 256 bits.\n\nIt contains only about:\n\n\\log_2(1,000,000)\\approx19.9\n\nbits of entropy.\n\nAn attacker can enumerate the entire space in ~1 million attempts.\n\nAnd there’s an even nastier issue\n\nEntropy doesn’t automatically accumulate just because you collect independent-looking data.\n\nIf you have sources A and B:\n\nH(A,B)=H(A)+H(B\\mid A)\n\nnot necessarily:\n\nH(A)+H(B)\n\nIf B is completely determined by A, then:\n\nH(B\\mid A)=0\n\nSo concatenating:\n\ntimestamp\nprocess ID\nmemory address\nCPU counter\nUUID\n\ndoesn’t give you the sum of their apparent bit widths.\n\nThat’s why modern cryptographic systems generally prefer:\n\nOS CSPRNG → cryptographic primitive → key\n\nrather than trying to invent an entropy-collection system themselves.",
"sig": "d1ba94645b1170b74ed309220737df100b6fa29a9b3d92fd4237dfea94bb0e96bff8b660ea518a98385e40a94d01113b819b1ffa6f74eeee9952da846ff9322b"
}