← Back to section · Foundations of Cryptography
Shannon Entropy: Information, Uncertainty and Cryptography's Unit of Account
Shannon turned «uncertainty» into a computable quantity with a single formula. This article explains the definition and intuition of entropy, conditional entropy and mutual information, and how Shannon used this language to prove what perfect secrecy costs — while marking the line between «high entropy» and «cryptographically secure».
In 1948 Shannon published “A Mathematical Theory of Communication” and, in passing, founded information theory. The most important tool cryptography borrowed from him is a formula measuring uncertainty — entropy. In cryptography entropy is not a metaphor: password strength, key spaces and the quality of randomness are all ultimately accounted in it. This article explains entropy and its close relatives, and restates Shannon’s own most important bequest to cryptography: the price of perfect secrecy.
Entropy: average surprise
Let a random variable X take values with probabilities p(x). Shannon entropy is H(X) = −Σ p(x) log₂ p(x), measured in bits. The intuition is “average surprise”: the less likely an outcome, the more information its occurrence carries (−log₂ p is larger), and entropy is the probability-weighted average. A fair coin has entropy exactly 1 bit; a coin that always lands heads has entropy 0 — no suspense, no information. If X is uniform over N values, H(X) = log₂ N is maximal; this is why “a 128-bit key” means “entropy 128 bits when drawn uniformly from 2^128 equally likely keys”.
A key character trait of entropy: it sees only the distribution, never the meaning. The same entropy value can belong to completely different systems; it measures uncertainty itself, not the use or value of the data. A frequently used variant is min-entropy, which looks only at the probability of the most likely value and measures the difficulty of “guessing right in one try”. When assessing passwords and random number generators, min-entropy is often more honest than average entropy — because the attacker always guesses the most likely value first. For example, a variable distributed 90%/10% has Shannon entropy of about 0.47 bits but min-entropy of only about 0.15 bits: on the average account it resembles half a coin; on the “guess it in one try” account it is almost always the high-probability value.
Rules of entropy arithmetic: joint entropy, the chain rule and the compression limit
Entropy comes with a compact calculus. The uncertainty of two variables together is the joint entropy H(X, Y), obeying the chain rule: H(X, Y) = H(X) + H(Y|X) — first the uncertainty of X, then what remains of Y once X is known. If X and Y are independent, the conditional term degenerates to H(Y) and joint entropy is simply the sum: for independent sources, uncertainties add directly. This rule is the basic craft of estimating a system’s total entropy: a key composed of two independently generated 64-bit random numbers has exactly 128 bits of entropy; if the two are correlated (derived from the same seed, say), the total falls below 128 bits, and the shortfall is precisely the mutual information. Shannon also proved entropy’s second identity: it is the limit of lossless compression — no lossless code can have average length below the entropy. Compression software can squeeze text close to its entropy but never below it; this also yields an operational test of “randomness”: truly random data is incompressible, and data that compresses noticeably has entropy below its apparent length.
Conditional entropy and mutual information: what remains after learning
How much uncertainty about X remains after learning Y? That is the conditional entropy H(X|Y). It never exceeds H(X): side information can only reduce (or leave unchanged) uncertainty. The difference I(X;Y) = H(X) − H(X|Y) is the mutual information, the amount of information X and Y share — symmetric and non-negative. This language seems made for cryptography: put the plaintext in place of X and the ciphertext in place of Y, and “how much the ciphertext leaks about the plaintext” becomes precisely I(plaintext; ciphertext). Side-channel attacks and traffic analysis are dangerous exactly because they push this mutual information above zero.
Shannon used it to define secrecy: an encryption system is perfectly secret if and only if, for every plaintext distribution, ciphertext and plaintext are independent, i.e. I(plaintext; ciphertext) = 0 — after seeing the ciphertext, uncertainty about the plaintext has not decreased at all. Vernam’s one-time pad (key as long as the message, truly random, used once) meets this definition: the ciphertext is a uniformly random string, entirely unrelated to the plaintext.
The price of perfect secrecy: Shannon’s lower bound
Shannon then proved a lower bound: in any perfectly secret system, the entropy of the key must be at least the entropy of the message. The intuitive argument is counting: to let every plaintext possibly encrypt to every ciphertext (otherwise the ciphertext would rule out some plaintexts, leaking information), there must be at least as many keys as plaintexts. This bound explains why the one-time pad does not scale: the key must be as long as the message, truly random, never reused — and distributing and guarding such keys is no easier than transmitting the messages securely in the first place. Modern cryptography therefore changed tracks: it abandons information-theoretic perfect secrecy in favour of computational security, allowing mutual information to be non-zero in principle while ensuring that no realistic computational budget can extract it in usable time. Public-key cryptography and computational complexity — the subject of another article in this section — are the products of that track.
Three entropy accounts in cryptographic engineering
Back in engineering, entropy is most often computed in three ledgers. The first is the password ledger: a password’s entropy depends on how it was generated, not on its length — user-chosen “long passwords” contain predictable patterns, so their real entropy is often far below the nominal value computed from the character set; this is why modern guidance recommends randomly generated passphrases and password managers. The second is the key-derivation ledger: key stretching such as PBKDF2, scrypt and Argon2 raises the cost of each guess but adds not one bit of entropy — it turns a low-entropy password into “slow to guess”, not “unguessable”, so derivation parameters (iteration counts, memory hardness) must be calibrated against the attacker’s computing power. The third is the random-generator ledger: the health of the system’s entropy sources caps the quality of key generation; entropy starvation in settings such as cloned virtual machines and first boot of embedded devices has been the root cause of multiple real-world key-repetition incidents. When engineers talk about entropy, in the end they are talking about these three concrete ledgers.
Drawing the line: high entropy is not security
Finally, an easily crossed line must be drawn: high entropy is necessary for security, not sufficient. A pseudorandom sequence whose output is perfectly uniform is worthless if its seed has only 32 bits of entropy — the attacker enumerates the seeds and predicts everything; uniformity of the distribution does not help, because entropy must be counted on the quantity the attacker does not know. Conversely, a compressible text may hold very high effective uncertainty for a particular attacker. Whenever cryptography speaks of entropy, ask three questions first: whose entropy, from whose viewpoint, under what distribution. Shannon’s formula supplies the unit of account; whose ledger the account is kept in is the user’s responsibility.
Tags: Information TheoryShannon EntropyPerfect Secrecy