Perfect secrecy requires at least as many keys as messages
OpenShannonSecrecy.perfect_secrecy_card_msg_le_card_keyShannon 1949, §10, p. 681. In a finite secrecy system with perfect secrecy, the number of different keys is at least as great as the number of messages.
Shannon's reasoning: for a fixed key , the map is a one-to-one correspondence between all the messages and some of the cryptograms, so there are at least as many cryptograms as messages. For perfect secrecy for any of these cryptograms and any message, hence there is at least one key transforming any given message into any of them. All the keys leading from a fixed message to different cryptograms must be different, and therefore the number of different keys is at least as great as the number of messages.
This is the first quantitative limitation on perfect secrecy, and the origin of the one-time-pad requirement that the key be at least as long as the message.
Formalization Note "Number of messages" and "number of keys" are the cardinalities of the finite types and ; the conclusion is the inequality . No nonemptiness is assumed: a key set is automatically nonempty because the key probabilities sum to , and keys of probability are allowed, so the counting argument must locate keys of positive probability.
import Definitions.Def_shannon_secrecy_system
namespace ShannonSecrecy
theorem perfect_secrecy_card_msg_le_card_key
{M K E : Type*} [Fintype M] [Fintype K] [Fintype E] [DecidableEq E]
(C : Cipher M K E) (h : PerfectSecrecy C) :
Fintype.card M ≤ Fintype.card K := by sorry
end ShannonSecrecyRead-back
What the Lean code literally says, in plain math · Aristotle (Harmonic) — NON-BLIND: same agent that drafted the statement
Provenance note — this read-back is NOT independent testimony. It is non-blind: it was written by the same agent that drafted the Lean statement it describes, working from the source paper and from its own formalization intent, and not by an independent auditor with a fresh context who saw only the Lean code. It therefore cannot corroborate the faithfulness of the formalization — an agreement between the statement and this read-back is self-agreement. Treat it as an annotation by the author, and obtain a blind read-back before relying on it during audit or moderation.
Let , , be finite types with decidable equality on , and let be a cipher on them: injective maps for each , together with weights satisfying .
Assume has the perfect-secrecy property, namely: for every with pointwise and , for every whose total probability
is nonzero, and for every , the ratio of to equals .
The conclusion is the inequality of natural numbers
that is, the number of elements of the message type is at most the number of elements of the key type. Nothing is claimed about . The hypothesis is not vacuous in general, but note two degenerate readings it permits: if is empty, there is no PMF on , so the perfect-secrecy hypothesis holds for every cipher and the conclusion is trivially true; keys of probability zero are permitted and are counted in .