Basics of Private Key Encryption 2
1. Lecture 7: Computational Security, Pseudorandom Generators, and Stream Ciphers
This lecture completes the transition from perfect secrecy to computational security.
The main ideas are:
- perfect secrecy is too strong for practical encryption with short keys;
- computational security only considers efficient adversaries;
- asymptotic security uses a security parameter \(\lambda\);
- efficient adversaries are modeled as PPT algorithms;
- small advantage means negligible advantage;
- cryptographic pseudorandom generators (PRGs) fool all efficient statistical tests;
- PRGs can be used to build IND-secure stream ciphers.
2. Review: Negligible Functions
The lecture starts by reviewing negligible functions, because they are the right asymptotic notion of “small advantage”.
A function
\[ f : \mathbb{N} \to \mathbb{R}_{\ge 0} \]
is negligible if it converges to zero faster than every inverse polynomial.
Formally, \(f\) is negligible if for every polynomial \(p\), there exists \(N \in \mathbb{N}\) such that for all \(n > N\),
\[ f(n) < \frac{1}{p(n)}. \]
Equivalently, it is enough to check polynomials of the form
\[ p(n) = n^c \]
for constants \(c > 0\). Thus \(f\) is negligible iff for every constant \(c > 0\), eventually
\[ f(n) < n^{-c}. \]
The lecture emphasized the following useful way to think about negligible functions:
\[ f(n) = n^{-\omega(1)}. \]
Here \(\omega(1)\) means a function that grows to infinity, possibly very slowly. So \(n^{-\omega(1)}\) means:
\[ f(n) \]
is smaller than
\[ n^{-c} \]
for every constant \(c\), once \(n\) is sufficiently large.
Another equivalent form is
\[ f(n) = 2^{-\omega(\log n)}. \]
Since
\[ 2^{\log n} = n, \]
we can rewrite
\[ 2^{-\omega(\log n)} \]
as
\[ n^{-\omega(1)}. \]
So the most useful intuition is:
\[ \boxed{ \text{negligible} \approx n^{-\text{superconstant}} } \]
where “superconstant” means growing beyond every fixed constant.
2.1. Simple test using logarithms
The lecture also recalled the rule:
\[ f \text{ is negligible} \iff -\log(f(n)) \ge \omega(\log n). \]
This means that the logarithmic decay of \(f\) must be faster than \(\log n\) by a superconstant factor.
For example:
\[ f(n) = 2^{-n} \]
is negligible because
\[ -\log(f(n)) = n, \]
and
\[ n = \omega(\log n). \]
But
\[ f(n) = n^{-100} \]
is not negligible, because
\[ -\log(f(n)) = 100 \log n, \]
which is only a constant multiple of \(\log n\), not \(\omega(\log n)\).
3. Full Definition of Encryption Schemes with a Security Parameter
The lecture then introduces the full asymptotic syntax of an encryption scheme.
An encryption scheme is a triple of PPT algorithms:
\[ (\mathsf{KeyGen}, \mathsf{Enc}, \mathsf{Dec}). \]
The important new feature is that \(\mathsf{KeyGen}\) now receives an explicit security parameter.
3.1. Security parameter
The security parameter is denoted by
\[ \lambda. \]
It is usually written in unary as
\[ 1^\lambda. \]
This means a string consisting of \(\lambda\) many \(1\)’s:
\[ 1^\lambda = \underbrace{11\cdots 1}_{\lambda \text{ times}}. \]
The reason for using unary is that the runtime of PPT algorithms should be polynomial in \(\lambda\), not polynomial in \(\log \lambda\).
3.2. Syntax
The algorithms are:
\[ \mathsf{KeyGen}(1^\lambda): \]
a randomized algorithm that takes the security parameter as input and outputs a key \(K\).
Typically, for symmetric encryption, one may think of
\[ K \in \{0,1\}^{\lambda}. \]
For example, \(\lambda = 128\) corresponds mentally to a 128-bit key.
\[ \mathsf{Enc}(K,m): \]
a possibly randomized algorithm that takes a key \(K\) and a message \(m\), and outputs a ciphertext \(c\).
\[ \mathsf{Dec}(K,c): \]
a deterministic algorithm that takes a key \(K\) and a ciphertext \(c\), and outputs a message \(m\).
3.3. Random coins / random tape
The professor emphasized that randomized algorithms can be viewed as having access to an infinite random tape.
For example, \(\mathsf{KeyGen}(1^\lambda)\) may read the first \(\lambda\) bits from its random tape and output them as the key.
This is a theoretical model of randomness. Cryptographers often call these random bits “random coins”.
3.4. Correctness
Correctness must hold for every security parameter.
For all
\[ \lambda \in \mathbb{N} \]
and all messages \(m\),
\[ \Pr[ \mathsf{Dec}(K,\mathsf{Enc}(K,m)) = m ] = 1, \]
where
\[ K \leftarrow \mathsf{KeyGen}(1^\lambda). \]
The probability is over the randomness of \(\mathsf{KeyGen}\) and \(\mathsf{Enc}\).
Correctness is required even for small \(\lambda\), although security may be meaningless for small \(\lambda\). For example, a 10-bit key can be brute-forced easily because there are only
\[ 2^{10} = 1024 \]
possible keys.
4. Computational Security: Asymptotic IND Security
The lecture then defines computational security in terms of indistinguishability.
In perfect secrecy, adversaries were computationally unbounded.
In computational security, adversaries are restricted to efficient algorithms, namely PPT machines.
4.1. PPT adversaries
PPT means:
\[ \text{Probabilistic Polynomial Time}. \]
So a PPT adversary is a randomized algorithm whose running time is polynomial in the security parameter \(\lambda\).
Thus:
\[ \boxed{ \text{efficient adversary} = \text{PPT adversary} } \]
4.2. The IND experiment
The indistinguishability experiment is denoted by
\[ \mathsf{IND}_{\mathcal{A}}(\lambda). \]
It depends on the security parameter \(\lambda\).
The experiment proceeds as follows.
The adversary \(\mathcal{A}\) outputs two messages:
\[ m_0, m_1. \]
The challenger generates a key:
\[ K \leftarrow \mathsf{KeyGen}(1^\lambda). \]
The challenger samples a random challenge bit:
\[ b \leftarrow_{\$} \{0,1\}. \]
The challenger encrypts \(m_b\):
\[ c^\ast \leftarrow \mathsf{Enc}(K,m_b). \]
The ciphertext \(c^\ast\) is called the challenge ciphertext.
The adversary receives \(c^\ast\) and outputs a guess:
\[ b'. \]
The experiment outputs \(1\) if the adversary guessed correctly:
\[ \mathsf{IND}_{\mathcal{A}}(\lambda) = 1 \iff b' = b. \]
Otherwise the experiment outputs \(0\).
So
\[ \Pr[\mathsf{IND}_{\mathcal{A}}(\lambda)=1] \]
is the winning probability of adversary \(\mathcal{A}\).
4.3. IND security
An encryption scheme
\[ (\mathsf{KeyGen},\mathsf{Enc},\mathsf{Dec}) \]
is IND-secure if for every PPT adversary \(\mathcal{A}\), there exists a negligible function \(\nu\) such that for all \(\lambda \in \mathbb{N}\),
\[ \Pr[\mathsf{IND}_{\mathcal{A}}(\lambda)=1] < \frac{1}{2} + \nu(\lambda). \]
Equivalently, every efficient adversary can do only negligibly better than random guessing.
The advantage of \(\mathcal{A}\) is
\begin{equation*} \mathsf{Adv}_{\mathcal{A}}(\lambda) = \Pr[\mathsf{IND}_{\mathcal{A}}(\lambda)=1] - \frac{1}{2}. \end{equation*}IND security requires:
\[ \mathsf{Adv}_{\mathcal{A}}(\lambda) \le \nu(\lambda) \]
for some negligible \(\nu\).
4.4. Difference from perfect secrecy
In perfect secrecy, every adversary has exactly winning probability
\[ \frac{1}{2}. \]
That is, the advantage is exactly zero.
In computational security, different PPT adversaries may have different advantages, depending on how much computation they use. The definition allows a small slack:
\[ \nu(\lambda). \]
This slack must be negligible.
Thus computational IND security is a relaxation of perfect secrecy.
5. Discussion: Asymptotic Security, Reductions, and Tight Security
The lecture then discusses what asymptotic security gives us and what it does not give us.
5.1. Standard assumptions
Asymptotic security allows us to base cryptographic security on standard computational assumptions.
These are computational problems that have been studied for a long time, often before their cryptographic relevance was known.
Examples of such assumptions include hardness assumptions like factoring large composite integers.
5.2. Reductions
The main method for proving security is a reduction.
A reduction connects the hardness of two problems.
The typical structure is:
\[ \text{If problem A is hard, then breaking scheme B is hard.} \]
To prove this, we argue contrapositive-style:
\[ \text{If someone can break scheme B, then we can solve problem A.} \]
So reductions usually go in the reverse direction.
Given:
\[ \text{an adversary against the new scheme}, \]
the reduction builds:
\[ \text{an algorithm or adversary against the underlying hard problem}. \]
This is the central proof technique for computational cryptography.
5.3. Limitation of asymptotic security
Asymptotic security does not tell us how to choose concrete parameters in practice.
For example, it does not directly tell us whether to use:
\[ 128\text{-bit keys}, \quad 256\text{-bit keys}, \quad 2048\text{-bit RSA}, \quad 4096\text{-bit RSA}. \]
Asymptotic security tells us that there is no structural design flaw in the scheme, assuming the underlying problem is hard.
It does not by itself provide exact practical security levels.
5.4. Tight security
The lecture mentions tight security as a newer trend that tries to reconcile asymptotic security with concrete guarantees.
A tight reduction means roughly:
If there is an adversary against the scheme with runtime \(T\) and advantage \(\epsilon\), then the reduction gives an algorithm against the underlying problem with essentially the same runtime and advantage.
Ideally:
\[ (T,\epsilon) \quad\text{against the scheme} \]
turns into approximately
\[ (T,\epsilon) \quad\text{against the assumption}. \]
So there is little or no security loss in the reduction.
This is important because many asymptotic proofs hide polynomial factors. In asymptotic security, polynomial factors are often swallowed up because
\[ \text{polynomial} \cdot \text{negligible} \]
is still negligible.
But for concrete security, these hidden polynomial losses may be too large.
So tight security aims to provide both:
- a solid asymptotic guarantee;
- a meaningful quantitative security guarantee.
6. Stream Ciphers: Basic Idea
The lecture then moves to stream ciphers.
The problem is:
Perfect secrecy requires the key to be at least as long as the message.
A stream cipher tries to solve this by taking a short key and expanding it into a long mask.
6.1. Basic recipe
Let
\[ K \in \{0,1\}^{\lambda} \]
be a short key.
Let
\[ G \]
be a deterministic function that expands \(K\) into a longer string:
\[ G(K) \in \{0,1\}^{\ell}. \]
Here usually
\[ \ell > \lambda. \]
Then use
\[ G(K) \]
as a one-time-pad-like mask.
Encryption:
\[ c = G(K) \oplus m. \]
Decryption:
\[ m = G(K) \oplus c. \]
This works because
\[ G(K) \oplus c = G(K) \oplus (G(K) \oplus m) = m. \]
6.2. Formal algorithms
The stream cipher construction is:
\[ \mathsf{KeyGen}(1^\lambda): \]
choose
\[ K \leftarrow_{\$} \{0,1\}^{\lambda} \]
uniformly at random and output \(K\).
\[ \mathsf{Enc}(K,m): \]
compute
\[ c \leftarrow G(K) \oplus m \]
and output \(c\).
\[ \mathsf{Dec}(K,c): \]
compute
\[ m \leftarrow G(K) \oplus c \]
and output \(m\).
6.3. Why \(G\) must be deterministic
The professor emphasized that \(G\) must be deterministic.
If \(G\) were randomized, then encryption and decryption might compute different masks.
Encryption might use one value:
\[ G(K;r_1), \]
while decryption might use another value:
\[ G(K;r_2). \]
Then correctness would fail.
Therefore, for this construction:
\[ \boxed{ G \text{ must be deterministic.} } \]
6.4. Security question
Correctness is easy.
The real question is:
\[ \text{What property must } G \text{ have for security?} \]
We want \(G(K)\) to behave like a uniformly random string.
However, \(G(K)\) cannot actually be uniformly distributed over \(\{0,1\}^{\ell}\), because \(K\) has only \(\lambda\) bits.
There are only
\[ 2^\lambda \]
possible keys, so there are at most
\[ 2^\lambda \]
possible outputs \(G(K)\).
But the set \(\{0,1\}^{\ell}\) has size
\[ 2^\ell. \]
If \(\ell > \lambda\), then
\[ 2^\lambda \ll 2^\ell. \]
Thus the distribution of \(G(K)\) has a sparse image.
Information-theoretically, it cannot equal the uniform distribution over \(\{0,1\}^{\ell}\).
So we need a computational notion:
\[ G(K) \]
should be indistinguishable from uniform for every efficient test.
This leads to pseudorandom generators.
7. Pseudorandomness against Simple Statistical Tests
The lecture gives historical motivation.
Early computer science already noticed that randomization can make algorithms more efficient. But early computers did not have good sources of true randomness.
So the idea was:
- start with a short random seed;
- expand it deterministically into a longer sequence;
- hope the output “looks random”.
7.1. Linear Feedback Shift Registers
One old construction is the Linear Feedback Shift Register, abbreviated LFSR.
An LFSR has a register of bits. At each clock cycle:
- the register shifts to one side;
- a new bit is computed as a linear function of some existing register bits;
- this new bit is inserted on the other side.
For example, the new bit might be
\[ x_{11} \oplus x_{13} \oplus x_{14} \oplus x_{16}. \]
This is a linear function over \(\mathbb{F}_2\).
LFSRs were designed to be efficient in hardware.
They can pass some simple statistical tests.
For example:
- they may be unbiased, meaning roughly the same number of \(0\)’s and \(1\)’s appear in the long run;
- they may have balanced runs, meaning the number of \(0\)-runs and \(1\)-runs of the same length is approximately the same.
A run is a consecutive block of equal bits, for example:
\[ 000 \]
is a run of three \(0\)’s, and
\[ 11 \]
is a run of two \(1\)’s.
7.2. Modular congruence generators
A software analogue popular in older systems is the modular congruence generator.
It has the form:
\[ x_{i+1} = a x_i + b \pmod N. \]
This is also linear, but over \(\mathbb{Z}_N\).
7.3. Why simple tests are not enough
LFSRs and modular congruence generators may pass simple tests like:
- bias tests;
- run tests.
But cryptography needs much more.
The problem is linearity.
If the output bits are generated by linear rules, then after observing enough output, an attacker can set up a system of linear equations and solve for the secret state using Gaussian elimination.
Solving linear systems is efficient.
Thus linear generators are not cryptographically secure.
The lesson is:
\[ \boxed{ \text{Passing a few chosen statistical tests is not enough.} } \]
Cryptographers want the output to fool all efficient tests.
8. Definition: Cryptographic Pseudorandom Generator
A cryptographic pseudorandom generator is a deterministic polynomial-time algorithm
\[ G : \{0,1\}^{\lambda} \to \{0,1\}^{\ell}, \]
where
\[ \ell = \operatorname{poly}(\lambda) \]
and usually
\[ \ell > \lambda. \]
The input \(K\) is called a key or seed.
The output is
\[ G(K). \]
Let
\[ u \leftarrow \{0,1\}^{\ell} \]
be a truly uniform random string of length \(\ell\).
8.1. Distinguisher
A distinguisher is an algorithm
\[ \mathcal{D} \]
that takes a string as input and outputs one bit:
\[ \mathcal{D}(x) \in \{0,1\}. \]
It represents an efficient statistical test.
8.2. PRG definition
\(G\) is a pseudorandom generator if for every PPT distinguisher \(\mathcal{D}\),
\begin{equation*} \left| \Pr[\mathcal{D}(G(K)) = 1] - \Pr[\mathcal{D}(u) = 1] \right| \le \operatorname{negl}(\lambda), \end{equation*}where
\[ K \leftarrow \{0,1\}^{\lambda}, \]
\[ u \leftarrow \{0,1\}^{\ell}, \]
and the probabilities also include the random coins of \(\mathcal{D}\).
Intuitively:
\[ \boxed{ G(K) \approx_c u } \]
meaning \(G(K)\) is computationally indistinguishable from uniform.
No efficient algorithm should be able to tell whether it received:
\[ G(K) \]
or
\[ u. \]
9. Truly Random Distributions vs. Pseudorandom Distributions
There is an important information-theoretic difference between a truly random distribution and a pseudorandom distribution.
The uniform distribution over
\[ \{0,1\}^{\ell} \]
has support size
\[ 2^\ell. \]
That means every string in \(\{0,1\}^{\ell}\) can occur.
But a PRG with seed length \(\lambda\) has at most
\[ 2^\lambda \]
possible outputs.
Thus the support size of \(G(K)\) is at most
\[ 2^\lambda. \]
If \(\ell > \lambda\), then this is a very sparse subset of \(\{0,1\}^{\ell}\).
For example, suppose
\[ \ell = 2\lambda. \]
Then the density of the image of \(G\) is at most
\[ \frac{2^\lambda}{2^{2\lambda}} = 2^{-\lambda}. \]
So if we sample a truly random string from
\[ \{0,1\}^{2\lambda}, \]
the probability that it lies in the image of \(G\) is at most
\[ 2^{-\lambda}. \]
This is exponentially small.
Thus pseudorandom distributions are statistically very far from uniform.
However, they are computationally indistinguishable from uniform.
This is the key cryptographic idea:
\[ \boxed{ \text{far from uniform information-theoretically,} \quad \text{but indistinguishable from uniform efficiently.} } \]
10. Example: Modular Congruence Generator
The lecture then gives an example of a generator that is not cryptographically secure.
Let \(P\) be a public prime.
Choose
\[ a,b \leftarrow \mathbb{Z}_P \]
and
\[ x_0 \leftarrow \mathbb{Z}_P. \]
Let the seed be
\[ s = (a,b,x_0). \]
Define the sequence:
\[ x_{i+1} = a x_i + b \pmod P. \]
Then the generator outputs
\[ x_0,x_1,\dots,x_\ell. \]
10.1. Is this a PRG?
No.
The reason is that the sequence is completely determined by three adjacent values.
From
\[ x_0,x_1,x_2, \]
we have
\[ x_1 = a x_0 + b \pmod P, \]
\[ x_2 = a x_1 + b \pmod P. \]
Subtracting gives:
\[ x_2 - x_1 = a(x_1 - x_0) \pmod P. \]
Assuming
\[ x_1 \neq x_0 \pmod P, \]
we can compute
\[ a = (x_2-x_1)(x_1-x_0)^{-1} \pmod P. \]
Then
\[ b = x_1 - a x_0 \pmod P. \]
So after seeing only a few outputs, the adversary can recover \(a\) and \(b\).
10.2. Distinguishing attack
A distinguisher can do the following:
- receive a sequence \(x_0,x_1,\dots,x_\ell\);
- compute \(a\) and \(b\) from \(x_0,x_1,x_2\);
test whether for every \(i > 2\),
\[ x_i = a x_{i-1} + b \pmod P. \]
For a sequence generated by the modular congruence generator, the test always passes.
For a truly uniform sequence, the probability that all remaining values satisfy the same recurrence is only about
\[ P^{-(\ell-3)}. \]
Therefore, the distinguishing advantage is approximately
\[ 1 - P^{-(\ell-3)}. \]
This is huge, not negligible.
So the modular congruence generator is not a cryptographic PRG.
11. Example: Modular Squares Generator / Blum-Blum-Shub
The lecture then gives a positive example.
Let
\[ N = P Q, \]
where \(P,Q\) are large randomly chosen primes.
Choose
\[ z_0 \leftarrow_{\$} \mathbb{Z}_N. \]
Define the internal state sequence:
\[ z_i = z_{i-1}^2 \pmod N. \]
If we simply output the full \(z_i\)’s, then this would not be pseudorandom, because the deterministic recurrence is publicly checkable.
Instead, output only the least significant bit of each state:
\[ x_i = \operatorname{LSB}(z_i). \]
So the output sequence is
\[ x_0,x_1,\dots,x_\ell. \]
The least significant bit tells whether \(z_i\) is even or odd.
11.1. Security statement
This generator is a PRG under the assumption that factoring
\[ N = P Q \]
is hard.
That is, given \(N\), it should be computationally hard to find \(P\) and \(Q\).
This is the Blum-Blum-Shub generator from 1982.
The lecture does not prove the reduction, because it requires extra number theory and the notion of hardcore bits.
The professor mentions that such proofs belong more naturally in an advanced course.
11.2. Comment about size of \(z_0\)
A student asked about the possibility that \(z_0\) is comparatively small.
The professor explained that if \(z_0\) is chosen uniformly modulo \(N\), then it will almost always have roughly the same bit length as \(N\).
For example, if \(N\) is 1024 bits and the top 100 bits of \(z_0\) are all zero, then the probability is about
\[ 2^{-100}. \]
So this kind of unusually small choice is very unlikely.
12. Constructing PRGs from Other PRGs
The lecture then discusses examples of building new candidate PRGs from given PRGs.
Let \(G\) and \(G'\) be PRGs.
12.1. Example 1: XOR with a fixed pseudorandom string
Define
\[ G_1(s) = G(s) \oplus G'(0^\lambda). \]
Here \(G'(0^\lambda)\) is fixed, because the input \(0^\lambda\) is fixed.
Question:
\[ \text{Is } G_1 \text{ a PRG?} \]
Answer:
\[ \boxed{\text{Yes.}} \]
Intuition:
If \(G(s)\) is pseudorandom, then XORing it with a fixed string should not make it distinguishable.
A truly uniform string remains truly uniform after XOR with any fixed string.
That is, if
\[ u \leftarrow \{0,1\}^{\ell}, \]
then
\[ u \oplus G'(0^\lambda) \]
is also uniformly distributed over \(\{0,1\}^{\ell}\).
12.2. Reduction proof
Assume for contradiction that \(G_1\) is not a PRG.
Then there exists a PPT distinguisher \(\mathcal{D}_1\) and a non-negligible \(\epsilon\) such that
\begin{equation*} \left| \Pr[\mathcal{D}_1(G_1(s))=1] - \Pr[\mathcal{D}_1(u)=1] \right| \ge \epsilon. \end{equation*}We build a distinguisher \(\mathcal{D}\) against \(G\).
Given input \(z\), define:
\[ \mathcal{D}(z) = \mathcal{D}_1(z \oplus G'(0^\lambda)). \]
Now consider two cases.
12.2.1. Case 1: \(z = G(s)\)
Then
\[ \mathcal{D}(G(s)) = \mathcal{D}_1(G(s) \oplus G'(0^\lambda)) = \mathcal{D}_1(G_1(s)). \]
So
\[ \Pr[\mathcal{D}(G(s))=1] = \Pr[\mathcal{D}_1(G_1(s))=1]. \]
12.2.2. Case 2: \(z = u\)
Then
\[ \mathcal{D}(u) = \mathcal{D}_1(u \oplus G'(0^\lambda)). \]
But
\[ u \oplus G'(0^\lambda) \]
is still uniform. Call it \(u'\).
So
\[ \Pr[\mathcal{D}(u)=1] = \Pr[\mathcal{D}_1(u')=1] = \Pr[\mathcal{D}_1(u)=1]. \]
Therefore,
\begin{equation*} \left| \Pr[\mathcal{D}(G(s))=1] - \Pr[\mathcal{D}(u)=1] \right| = \left| \Pr[\mathcal{D}_1(G_1(s))=1] - \Pr[\mathcal{D}_1(u)=1] \right| \ge \epsilon. \end{equation*}Thus \(\mathcal{D}\) distinguishes \(G(s)\) from uniform with non-negligible advantage.
This contradicts the assumption that \(G\) is a PRG.
Therefore \(G_1\) is a PRG.
This is an example of a simple security reduction.
12.3. Example 2: Reusing the same seed in two PRGs
Now define
\[ G_2(s) = G(s) \oplus G'(s). \]
Question:
\[ \text{Is } G_2 \text{ necessarily a PRG?} \]
Answer:
\[ \boxed{\text{No.}} \]
Counterexample:
Let
\[ G' = G. \]
Then
\[ G_2(s) = G(s) \oplus G(s) = 0^\ell. \]
This is the all-zero string, which is trivially distinguishable from uniform.
A distinguisher can simply check whether the input equals \(0^\ell\).
This shows that reusing the same seed can destroy pseudorandomness.
12.4. What if \(G\) and \(G'\) are different algorithms?
The professor also explains that merely requiring \(G\) and \(G'\) to be different functions does not fix the problem.
For example, define
\[ G'(s) = G(s) \oplus 1^\ell. \]
Then \(G'\) is a different function from \(G\), but
\[ G(s) \oplus G'(s) = G(s) \oplus (G(s) \oplus 1^\ell) = 1^\ell. \]
Again the output is constant, hence easily distinguishable from uniform.
12.5. Takeaway
The important takeaway is:
\[ \boxed{ \text{PRG seeds / keys should not be reused.} } \]
If we used independent seeds \(s_1\) and \(s_2\), then combining outputs may be safe under suitable reasoning.
But using the same seed twice is dangerous.
13. Security of Stream Ciphers
The lecture returns to the stream cipher construction:
\[ \mathsf{KeyGen}(1^\lambda): K \leftarrow_{\$} \{0,1\}^{\lambda}. \]
\[ \mathsf{Enc}(K,m): c = G(K) \oplus m. \]
\[ \mathsf{Dec}(K,c): m = G(K) \oplus c. \]
The theorem is:
\[ \boxed{ \text{If } G \text{ is a PRG, then this stream cipher is IND-secure.} } \]
14. Proof: PRG Implies IND-Secure Stream Cipher
The proof is by contraposition / reduction.
We want to prove:
\[ G \text{ is a PRG} \implies (\mathsf{KeyGen},\mathsf{Enc},\mathsf{Dec}) \text{ is IND-secure}. \]
By contraposition, assume the stream cipher is not IND-secure.
Then there exists a PPT adversary \(\mathcal{A}\) and a non-negligible \(\epsilon\) such that
\[ \Pr[\mathsf{IND}_{\mathcal{A}}(\lambda)=1] \ge \frac{1}{2} + \epsilon. \]
We will build a PPT distinguisher \(\mathcal{D}\) against \(G\) with advantage \(\epsilon\).
14.1. Strategy
The distinguisher \(\mathcal{D}\) receives an input
\[ z \in \{0,1\}^{\ell}. \]
This \(z\) is either:
\[ z = G(K) \]
for a random seed \(K\), or
\[ z = u \]
for a truly uniform random string \(u\).
The distinguisher \(\mathcal{D}\) internally simulates the IND experiment for \(\mathcal{A}\).
The only difference is that instead of generating a real stream cipher mask \(G(K)\), it uses its own input \(z\) as the mask.
14.2. Construction of the distinguisher \(\mathcal{D}\)
On input \(z\):
Run \(\mathcal{A}\) to obtain two messages:
\[ m_0,m_1. \]
Sample a random bit:
\[ b \leftarrow_{\$} \{0,1\}. \]
Compute the challenge ciphertext:
\[ c^\ast = z \oplus m_b. \]
- Give \(c^\ast\) to \(\mathcal{A}\).
- Receive \(\mathcal{A}\)’s guess \(b'\).
Output \(1\) if
\[ b' = b. \]
Otherwise output \(0\).
Here output \(1\) means that \(\mathcal{D}\) guesses its input was pseudorandom.
14.3. Case 1: \(z = G(K)\)
If
\[ z = G(K), \]
then the challenge ciphertext is
\[ c^\ast = G(K) \oplus m_b. \]
This is exactly a real encryption of \(m_b\) under the stream cipher.
So from \(\mathcal{A}\)’s point of view, the simulation is exactly the real IND experiment.
Therefore,
\[ \Pr[\mathcal{D}(G(K))=1] = \Pr[\mathsf{IND}_{\mathcal{A}}(\lambda)=1]. \]
By assumption,
\[ \Pr[\mathcal{D}(G(K))=1] \ge \frac{1}{2}+\epsilon. \]
14.4. Case 2: \(z = u\)
If
\[ z = u \]
is truly uniform, then the challenge ciphertext is
\[ c^\ast = u \oplus m_b. \]
This is exactly the one-time pad experiment.
Because the one-time pad is perfectly secret, the adversary has no information about \(b\).
Therefore,
\[ \Pr[\mathcal{D}(u)=1] = \frac{1}{2}. \]
14.5. Advantage of \(\mathcal{D}\)
The distinguishing advantage is
\begin{equation*} \Pr[\mathcal{D}(G(K))=1] - \Pr[\mathcal{D}(u)=1]. \end{equation*}Using the two cases above:
\begin{equation*} \Pr[\mathcal{D}(G(K))=1] - \Pr[\mathcal{D}(u)=1] \ge \left(\frac{1}{2}+\epsilon\right) - \frac{1}{2} = \epsilon. \end{equation*}Since \(\epsilon\) is non-negligible, \(\mathcal{D}\) breaks the PRG security of \(G\).
This contradicts the assumption that \(G\) is a PRG.
Therefore, the stream cipher is IND-secure.
15. Final Summary of the Lecture
The lecture concludes with the following key points.
15.1. Perfect security is both overkill and insufficient
Perfect secrecy is too strong for practical encryption with short keys.
Shannon’s theorem says that perfectly secret encryption requires the key to be as long as the message and cannot safely reuse the key.
Also, secrecy alone is not enough for all security goals. There can be attacks that do not reveal the message but still manipulate ciphertexts.
15.2. Computational security
Computational security restricts attention to efficient adversaries.
Instead of requiring that no adversary gains any information, we require that no efficient adversary gains more than negligible advantage.
15.3. Asymptotic security
In asymptotic security:
\[ \text{efficient adversary} = \text{PPT algorithm}, \]
and
\[ \text{small advantage} = \text{negligible advantage}. \]
15.4. PRGs
A cryptographic PRG is a deterministic polynomial-time algorithm that expands a short random seed into a longer output.
The output distribution is statistically far from uniform because it has a sparse image.
However, it must be computationally indistinguishable from uniform.
In other words, it must fool all efficient statistical tests.
15.5. Stream ciphers
A stream cipher uses a PRG to expand a short key into a long mask.
Then encryption is:
\[ c = G(K) \oplus m. \]
Decryption is:
\[ m = G(K) \oplus c. \]
If \(G\) is a secure PRG, then this stream cipher is IND-secure.
The proof is a reduction:
\[ \text{IND adversary against stream cipher} \implies \text{distinguisher against PRG}. \]
Thus PRGs provide a clean way to build computationally secure encryption with keys shorter than the message.