Defining Security

Why Encryption Must Be Randomized The Indistinguishability Game Semantic Security The Two Definitions Agree Stronger Notions

Why Encryption Must Be Randomized

The previous page fixed an encryption scheme as a family of injective maps \(E_e \colon \mathcal{M} \to \mathcal{C}\), one per key, and treated each \(E_e\) as a fixed function, so that a given plaintext under a given key always produces the same ciphertext. We flagged there that this deterministic choice carries a weakness, and set the repair aside. We collect that debt now. The weakness is not a detail of one construction but a barrier that no deterministic scheme can clear once its key is reused or the adversary can encrypt under that key. The security definitions that follow are built to measure exactly what clearing that barrier requires.

Fix a key and consider what a deterministic \(E_e\) leaks before any question of key recovery arises. Three failures are structural, regardless of how hard the key is to find. The first appears once the key encrypts more than one message, and the second once the adversary can obtain encryptions.

1. Repetition.
Because \(E_e\) is a function, \(m = m'\) forces \(E_e(m) = E_e(m')\), so equal plaintexts produce equal ciphertexts. An observer who sees the same ciphertext twice learns that the same message was sent twice, without breaking anything, since the equality of ciphertexts is visible directly. In a setting where messages recur, the pattern of repetitions is itself information, and a deterministic scheme transmits it in the clear.

2. Distribution dependence.
Suppose the adversary knows that the plaintext is drawn from a small or skewed set, such as a yes/no instruction, a choice among a handful of fixed commands, or a field whose likely values are few. Under Kerckhoffs's principle the scheme itself is public. If the encryption transformation is also public to the adversary, as in a public-key setting, the adversary can encrypt each likely plaintext directly. Even when the transformation is not public, a chosen-plaintext adversary can obtain such encryptions. Either way the adversary can compare against the observed ciphertext. A deterministic scheme offers no defense here, because the ciphertext it produces for a given plaintext is a fixed target the adversary can reproduce and match.

3. Partial information.
The third sharpens the second. Even when the adversary cannot recover the whole plaintext, a deterministic scheme may leak some part of it, for instance a predicate, a fragment, or a single bit that the ciphertext determines and the adversary can compute. Recovering the plaintext in full is only the crudest notion of a break. A scheme that hides the message but discloses a reliable bit of it has still failed against an adversary who needs only that bit. The work of the sections ahead is to make this precise: what it means to leak nothing, not merely to hide the whole.

All three failures share one root. A deterministic \(E_e\) is a fixed map, so the ciphertext is a deterministic function of the plaintext, and any structure in the plaintext passes through to structure in the ciphertext that the adversary can read or reproduce. The repair is to break the functional dependence. A randomized encryption scheme draws fresh randomness at encryption time, so that a single plaintext maps to many possible ciphertexts and the particular one sent carries no reproducible signature of the plaintext's structure.

Definition: Randomized Encryption

A randomized encryption scheme augments encryption with a space \(\mathcal{R}\) of random values. Encryption under key \(e\) is a map \[ E_e \colon \mathcal{M} \times \mathcal{R} \to \mathcal{C}, \] and to encrypt a plaintext \(m\) the sender draws \(r \in \mathcal{R}\) afresh, uniformly and independently of past encryptions, and transmits \(E_e(m, r)\). Decryption recovers the plaintext from the ciphertext alone. There is a map \(D_d\) with \[ D_d\bigl(E_e(m, r)\bigr) = m \quad \text{for every } m \in \mathcal{M} \text{ and every } r \in \mathcal{R}. \] For each fixed \(m\), varying \(r\) ranges over a set of ciphertexts all decrypting to \(m\). Encryption is no longer a function of the plaintext alone but can be a one-to-many assignment, while decryption remains unambiguous.

The decryption condition forces a structural fact: distinct plaintexts must have disjoint ciphertext sets. If some ciphertext \(c\) could arise as \(E_e(m, r)\) and also as \(E_e(m', r')\) with \(m \neq m'\), then \(D_d(c)\) would have to equal both \(m\) and \(m'\), contradicting that decryption returns a single plaintext. Each plaintext owns a private region of \(\mathcal{C}\), and randomness selects which point of its own region a given encryption lands on. Re-encrypting a message draws a fresh point from the same region, so an adversary that encrypts a candidate plaintext itself matches the sender's point only when its own draw lands on that point.

Randomization is the precondition for the security this page defines, not an optional hardening of it. But possibility is not security. A plaintext having many ciphertexts is worthless if the adversary can still tell one plaintext's ciphertexts from another's. We need a definition that holds the scheme to the right standard. That standard is not "the adversary cannot recover the key," nor even "cannot recover the plaintext," but "cannot extract anything the plaintext was meant to hide."

The Indistinguishability Game

We want a definition of security that captures "the ciphertext reveals nothing useful," and we want it phrased so that it can be checked. The route is to turn security into a contest the adversary plays and is required to lose. If the best the adversary can do is no better than guessing, the scheme leaks nothing the adversary could act on.

The contest is sharp precisely because the adversary is handed a strong advantage, though never the key. Rather than wait for messages it cannot control, the adversary itself names the two plaintexts whose encryptions it will try to tell apart. Knowing the candidates exactly, it faces the easiest possible discrimination task. It is then shown the encryption of one of them, chosen by a fair coin it cannot see, and asked which. A scheme that hides information must defeat the adversary even on this self-chosen, two-way choice. If it leaks enough to bias that one guess, it has leaked something.

Definition: Indistinguishability of Encryptions

Security is measured by the following game between a challenger and an adversary \(\mathcal{A}\), played at security parameter \(n\) (the key length). Key generation and encryption are public algorithms running in time polynomial in \(n\), and plaintexts have length polynomial in \(n\). Here and below, every algorithm, the adversary included, may use random coins. Once the challenger has drawn the key in step 2, \(\mathcal{A}\) may encrypt plaintexts of its own choosing. In a public-key setting the encryption key is public, and in a shared-key setting this ability is the chosen-plaintext access granted by the attack model of the previous page.

  1. Before any key is drawn, \(\mathcal{A}\) selects two plaintexts \(m_0, m_1 \in \mathcal{M}\) of equal length and submits both to the challenger.
  2. The challenger draws the key, a bit \(b \in \{0, 1\}\) uniformly at random, and a random value \(r \in \mathcal{R}\), computes the challenge ciphertext \(c = E_e(m_b, r)\), and returns \(c\) to \(\mathcal{A}\).
  3. \(\mathcal{A}\) outputs a guess \(b' \in \{0, 1\}\) and wins if \(b' = b\).

The scheme has indistinguishable encryptions if every adversary running in polynomial time in \(n\), even one given an advice string of length polynomial in \(n\) that depends only on \(n\), wins with probability at most \[ \Pr[b' = b] \le \tfrac{1}{2} + \varepsilon(n), \] where the advantage \(\varepsilon(n)\) over a blind coin-flip is negligible, meaning that it shrinks faster than the reciprocal of any polynomial in \(n\).

Three features of the game are deliberate, and each answers a question the previous page left open.

The bound is stated against polynomial-time adversaries. This is where the complexity notions invoked on the previous page enter the definition itself. "The adversary cannot win" does not mean that no winning strategy exists in principle, since exhaustive key search always exists. It means that no strategy runs within the resource budget of a feasible attacker, made precise as time polynomial in the security parameter. The advice string accounts for an attacker who has fixed in advance, for each key length, information such as a well-chosen pair of plaintexts. A scheme is secure against the bounded adversary the previous page described, not against an unbounded one. Security against an unbounded adversary is the separate guarantee of perfect secrecy from the previous page, where the adversary observes a single ciphertext and has no encryption access.

The winning margin must be negligible. An adversary can always achieve exactly \(\tfrac{1}{2}\) by ignoring the ciphertext and flipping its own coin, and can do slightly better by luck on any given run. What security forbids is a margin that a feasible attacker can convert into a reliable advantage. A permitted margin must be small enough to be little-o of every inverse polynomial, so that it cannot be amplified into a usable edge by repeating the attack a feasible number of times. This is the precise form of the "non-negligible probability" the previous page used to separate a genuine break from a lucky guess.

The adversary chooses the plaintexts. Together with encryption access, this feature subsumes the first two deterministic failures from the first section at once. If the scheme were deterministic, the adversary would name any two distinct plaintexts of equal length, encrypt \(m_0\) itself, and compare with the challenge. A match reveals \(b = 0\) and a mismatch reveals \(b = 1\), so the adversary wins with certainty. Indistinguishability is therefore unattainable for deterministic schemes, unless no two distinct plaintexts share a length, in which case the length alone gives the plaintext away and there is nothing left to hide. The game formalizes exactly why a fixed map had to be abandoned.

The same feature also addresses distribution dependence. By letting the adversary pick the worst pair of plaintexts, the definition demands security in the worst case, not merely on average. Covering every distribution over messages of a given length is a further step, taken later on this page by showing the definition equivalent to a second one.

One further constraint of the game is not a design choice but an honest accounting of what encryption does not promise to hide. The plaintexts \(m_0\) and \(m_1\) are required to have equal length. A ciphertext generally reveals the length of its plaintext, and an adversary allowed to submit plaintexts of different lengths could win trivially by reading off the ciphertext size, defeating the scheme for a reason that has nothing to do with the secrecy of content. Fixing equal lengths isolates the property we actually want: that nothing about the content leaks. Concealing length is a separate concern that these definitions leave aside.

Semantic Security

The indistinguishability game is a clean test, but it phrases security negatively and narrowly, as the adversary's failure to win one specific two-way guessing contest. The intuition we began with was broader and positive. A ciphertext should betray nothing about its plaintext that the adversary could not already have known. We now state that intuition directly, in a form that makes no reference to any game.

The difficulty is to say what "betray nothing" means without smuggling in a list of forbidden leaks. We cannot enumerate every fact an adversary might extract, such as a parity bit, a price bracket, or whether the message names a particular person. The semantic formulation avoids the list by comparing two worlds. In one, the adversary holds the ciphertext. In the other, it holds nothing but the length of the plaintext and advice fixed in advance. The scheme is secure if these two worlds are computationally the same, that is, if anything the adversary can compute from the ciphertext it could already compute without it.

Definition: Semantic Security

A scheme is semantically secure if whatever a polynomial-time adversary can compute about the plaintext from the ciphertext, it can already compute in polynomial time without the ciphertext, for every distribution over the message space. Formally, let \(\mathcal{A}\) be any polynomial-time adversary, possibly given an advice string of polynomial length depending only on \(n\), that receives a challenge ciphertext and has the same encryption access as in the indistinguishability game. Then there is a polynomial-time simulator \(\mathcal{S}\), given neither the ciphertext nor that access but only the length of the plaintext and an advice string of polynomial length depending only on \(n\), with the following property. For every distribution over the message space and every function \(f\) of the plaintext the adversary might wish to compute, when the plaintext \(m\) is drawn from that distribution, the probability that \(\mathcal{A}\) correctly computes \(f(m)\) exceeds the probability that \(\mathcal{S}\) does so by only a negligible amount.

The simulator is the heart of the definition. It is a hypothetical algorithm that must reproduce the adversary's success while being denied the ciphertext and any use of the real key. If such a simulator always exists, the ciphertext was useless to the adversary. Every inference it supported was already available from the plaintext's length together with advice fixed in advance.

The semantic definition retires the third deterministic failure from the first section. There we observed that a scheme can hide a plaintext in full yet leak a reliable bit of it, and that recovering the whole message is too crude a notion of a break.

Semantic security is the notion that is not too crude. It forbids leaking any function \(f\) of the plaintext, from the whole message down to a single predicate, because \(f\) ranges over everything the adversary might want. A scheme that disclosed even one reliable bit, one unpredictable without the ciphertext, would be caught, because that bit is an \(f\) that the adversary computes from the ciphertext and no simulator can match.

The definition also ties secrecy to the whole message distribution rather than to a single message. The guarantee is quantified over every distribution, and it must hold whether the plaintext is a uniform random string or one of two known commands. The indistinguishability game aimed at the same universality from the opposite side, by letting the adversary choose the plaintexts. There the adversary picks the worst case, and here the guarantee holds in all cases. That the two routes lead to the same place is the content of the next section.

The Two Definitions Agree

We now have two definitions of the same intention. Indistinguishability is operational and narrow. It asks only that the adversary win a two-way guessing game no more often than chance. Semantic security is conceptual and broad. It asks that no function of the plaintext leak beyond what its length already reveals. The first is the form a proof about a scheme works with, and the second states what we want. Their value comes from a single fact: they are the same condition.

Theorem: Equivalence of Security Definitions

A scheme has indistinguishable encryptions if and only if it is semantically secure.

Equivalence of the two security definitions Indistinguishability and semantic security are connected by two implications: the easy direction is proved by contraposition, the hard direction by constructing a decoy simulator. Indistinguishability guess no better than chance Semantic security leak nothing about the message hard: decoy simulator easy: contraposition if and only if

The two directions are unequal in difficulty, and seeing why is more instructive than a formal reduction. We give the mechanism of each.

Semantic security implies indistinguishability.
This direction is immediate in contrapositive, because an adversary who wins the indistinguishability game is already a violation of semantic security. Suppose some adversary distinguishes the encryptions of its two chosen plaintexts with non-negligible advantage. We fix, as part of its advice, random coins for step 1 of the game that do not lower this advantage. The fixed coins pin down one pair \(m_0, m_1\) for each \(n\), and the two are distinct at every \(n\) where the advantage is positive, the only \(n\) the argument needs. Take the message distribution in the semantic definition to be uniform on \(\{m_0, m_1\}\), and take the function \(f\) to be the single bit "is the plaintext \(m_1\) rather than \(m_0\)." From the ciphertext, the winning adversary computes this bit with probability non-negligibly above one half. No simulator denied the ciphertext can match this. A simulator knows only that the plaintext is one of \(m_0, m_1\), each equally likely, so its best blind guess of the bit succeeds with probability exactly one half. The adversary's edge over every simulator is therefore non-negligible, which is precisely the failure of semantic security. A semantically secure scheme thus admits no distinguishing adversary and has indistinguishable encryptions.

Indistinguishability implies semantic security.
This direction carries the real content, and its mechanism is the construction of a simulator. We are given that no efficient adversary wins the guessing game, and must produce, for any adversary \(\mathcal{A}\) that computes some \(f(m)\) from the ciphertext, a simulator \(\mathcal{S}\) that does as well without it. The simulator's strategy is to run \(\mathcal{A}\) on a decoy. Rather than the true ciphertext, which it does not have, \(\mathcal{S}\) encrypts a fixed dummy plaintext of the correct length, drawing the randomness itself, and feeds the result to \(\mathcal{A}\). The simulator can do this because the scheme itself, key generation included, is public and runs in polynomial time. Concretely, \(\mathcal{S}\) draws a fresh key pair of its own, distributed like the real one, encrypts the dummy under it, and answers every encryption request of \(\mathcal{A}\) under the same key pair. Indistinguishability guarantees that the chance that \(\mathcal{A}\) outputs \(f(m)\) cannot drop non-negligibly from the real run to the decoy run. Suppose that, averaged over the message distribution, it did. For each \(n\), let \(m\) be a plaintext at which the drop is at least this average. A distinguisher given \(m\) and \(f(m)\) as advice would submit \(m\) and the dummy, run \(\mathcal{A}\) on the challenge while answering the encryption requests of \(\mathcal{A}\) through the game's encryption access, and guess that \(m\) was encrypted exactly when \(\mathcal{A}\) outputs \(f(m)\). That distinguisher would itself win the guessing game with advantage half that drop, which is non-negligible. So \(\mathcal{A}\) computes \(f\) on the decoy run essentially as well as it would have on the real ciphertext, and the simulator simply reports \(\mathcal{A}\)'s output. The ciphertext is thereby shown to have been dispensable. Whatever \(\mathcal{A}\) extracted from it could be extracted from a decoy carrying nothing of the true plaintext beyond its length.

Math \(\leftrightarrow\) CS: Why the Equivalence Is Workable

The equivalence is what makes the theory practicable. One proves indistinguishability and obtains semantic security, the guarantee one cares about, for free. Indistinguishability is a game-shaped obligation, and for a concrete scheme it is discharged by a reduction to a hardness assumption about some underlying problem. Later claims that a scheme "leaks nothing about the plaintext" are established this way: not by arguing directly that no function leaks, which quantifies over all functions and all distributions, but by showing that no efficient adversary wins a single guessing game.

The equivalence also closes the account opened on the previous page, where security split into the unconditional and the computational. Perfect secrecy demanded that the ciphertext be statistically independent of the plaintext, so that even an adversary of unlimited power gains no information from it, and we saw it costs a key at least as long as the message.

Semantic security is the computational shadow of that demand. The ciphertext need not be independent of the plaintext, only independent as far as a polynomial-time adversary can tell. Relaxing "no information" to "no efficiently extractable information" is exactly what lifts the key-length barrier. Under a hardness assumption, a short key can then protect a long message, which is the trade the one-time pad could not make.

Stronger Notions

Semantic security, in either of its equivalent forms, is the baseline an encryption scheme is expected to meet. It is not the ceiling. The guessing game of this page gave the adversary one specific power, the ability to choose plaintexts and see their encryptions. Real adversaries have more. Strengthening the definition is a matter of enlarging what the adversary may do, and the same game-shaped template absorbs each enlargement.

The first enlargement follows the attack hierarchy of the previous page. The indistinguishability game as stated lets the adversary obtain encryptions of plaintexts it chooses, and so defines a form of security against a chosen-plaintext attack. But the previous page placed a stronger adversary above the chosen-plaintext one. That adversary can also obtain decryptions of ciphertexts of its choosing, even adaptively and even after seeing the challenge, though never of the target ciphertext itself.

Granting the game's adversary that decryption access, and still demanding it cannot win, defines a form of security against an adaptive chosen-ciphertext attack. The definition keeps its shape, since it is the same guessing game with a more powerful player. The bar, however, is far higher, and schemes deployed in adversarial settings are held to it because real systems do decrypt attacker-supplied ciphertexts. Letting the adversary choose \(m_0, m_1\) only after it has seen encryptions or a public encryption key strengthens the game in the same way.

A second strengthening asks for something the guessing game does not directly address: non-malleability. A scheme is malleable if, given a ciphertext, an adversary can produce a different ciphertext whose plaintext is related to the original in a controlled way, without ever learning either plaintext. Indistinguishability forbids reading the message, and non-malleability forbids tampering with it coherently.

Non-malleability is the stronger requirement. A non-malleable scheme is also semantically secure, so non-malleability sits above the baseline of this page. The distinction matters wherever a ciphertext is not merely read but acted upon, as with a transferred amount or a command, since there the threat is an adversary who alters the effect without breaking the secrecy.

Two strengthenings of semantic security From a baseline of semantic security against a chosen-plaintext adversary, two strengthenings branch out: chosen-ciphertext security strengthens the adversary, while non-malleability changes the goal from reading to tampering. Chosen-ciphertext security stronger adversary: gets decryptions Non-malleability different goal: no tampering Semantic security baseline: chosen-plaintext adversary strengthen adversary change goal

These notions branch from a single baseline along two axes, and the branching pattern is itself the durable object. Each stronger notion is the same construction, instantiated against a stronger adversary or aimed at a different goal. The construction is a game in which an adversary, granted some catalog of powers, must fail to win. The catalog grows, but the shape does not.

The template belongs to the framework the previous page promised would survive even a change in the model of computation. The definitions of security are requirements on what a bounded adversary cannot do, and the games keep their shape whatever the adversary is built from, classical or quantum. What a quantum adversary changes is the class of adversaries the games range over, from classical to quantum machines running in polynomial time. That shift alters which schemes meet the definitions. Some problems conjectured hard for classical machines, factoring and the discrete logarithm among them, are solved efficiently by a quantum algorithm, so schemes that fall once those problems are solved do not meet the definitions against quantum adversaries. The shift also alters which schemes can be proved to meet them, because some reductions may not carry over to quantum adversaries.

Every security guarantee on this page is conditional. A scheme is secure if no efficient adversary wins, and whether one exists turns on the hardness of some computational problem the scheme is built from. We have defined what security means without yet exhibiting a single scheme that achieves it, because achieving it requires a problem believed intractable and a way to bind a scheme's security to that problem.