COMP3357 - 2023-Lec 4
COMP3357 - 2023-Lec 4
COMP3357 - 2023-Lec 4
Ravi Ramanathan
We've seen that by Shannon's theorem, the only way to achieve perfect secrecy is to have keys
This is quite impractical. We'd like to encrypt a document (say several MB) using a key of few hundred bits.
To do this, we consider weaker, more practical adversaries, that are computationally bounded.
These adversaries perform attacks using real computers with practical limits on time and memory.
Also, we ask that encryption and decryption be themselves efficient algorithms, rather than arbitrary ones.
Security Parameter n
We consider security parameter n (an integer) chosen by the honest parties beforehand.
Also, since we want to use short keys, we will allow schemes in which the adversaries succeed
An algorithm 𝒜 runs in polynomial time if there exists a polynomial p such that for every
We write the security parameter in unary as 1n so that we can view the algorithm as
A probabilistic (randomized) algorithm is one that has access to a source of randomness that yields
A randomized algorithm is considered to give more power to adversary than a deterministic one.
Probabilistic Polynomial Time Adversaries
A PPT adversary is a probabilistic algorithm that can only perform a polynomial amount of
operations and has access to a polynomial number of random bits.
By the Extended Church-Turing thesis, all ‘reasonable’ models of computation are polynomially
equivalent, so the notion of PPT adversary is justified, independent of the resources available
to the attacker.
Redefining Private Key Encryption
1. The key-generation algorithm Gen takes as input 1n and outputs a key k, i.e., k ← Gen(1n) .
2. The encryption algorithm Enc takes as input a key k and a plaintext message m ∈ {0,1}*,
3. The decryption algorithm Dec takes as input a key k and a ciphertext c, and outputs a
message m or error ⊥ . We write m := Deck(c) when Dec does not return an error.
Adversarial Indistinguishability Experiment PrivKeav
𝒜,Π(n) :
We now define Computational (aka Semantic or EAV) Security against a single ciphertext-only attack.
1. The adversary 𝒜 is given input 1n and outputs a pair of messages m0, m1 with | m0 | = | m1 | .
2. A key k is generated by running Gen (1n) and a uniform bit b ∈ {0,1} is chosen.
Challenge ciphertext c ← Enck (mb) is computed and given to 𝒜 .
S. Goldwasser and S. Micali. Probabilistic Encryption. Journal of Computer and System Sciences, 28(2): 270-299 (1984).
Adversarial Indistinguishability Experiment PrivKeav
𝒜,Π(n) :
and does not have any other interaction with sender or receiver.
Challenger A
m0 , m 1 2 M
R
b {0, 1}
R
k K
R
c E(k, mb ) c
b̂ 2 {0, 1}
Definition. A private-key encryption scheme Π = (Gen, Enc, Dec) has indistinguishable encryptions
probabilistic polynomial-time adversaries 𝒜 there is a negligible function ϵ such that for all n,
1
Pr [PrivKeav
𝒜,Π (n) = 1 ] 2 + ϵ(n) .
≤
Here, the probability is taken over the randomness used by 𝒜 and the randomness used in the
experiment for choosing k, and b, as well as any randomness used by Enc .
S. Goldwasser and S. Micali. Probabilistic Encryption. Journal of Computer and System Sciences, 28(2): 270-299 (1984).
Negligible Success Probability: Negligible Functions
A negligible function is one that is asymptotically smaller than any inverse polynomial function.
Equivalently, function f : ℕ → ℝ≥0 is negligible if for all constants c there exists an N such that
for all n > N it holds that f (n) < n −c . We denote a negligible function by ϵ(n) .
1/4 1/3
Typical negligible functions: f(n) = 2−n, 2− n
, e −n , n 42−cn, 2−c′ n , 2−c′′n , n −log2 n .
Equivalently, a function f : ℕ → ℝ≥0 is negligible if and only if for all c > 0, we have
lim f (n) ⋅ n c = 0.
n→∞
−100 1
Some examples of non-negligible functions include n , .
100n 4 + n 2 log n
1
2n
for odd n
Example. Suppose we have a function defined as g(n) := 1
for even n
n8
1
This function g(n) is not negligible since there is no N for which g(n) < for all n > N .
n 9
1/3
Q1. Find N such that (a) f1(n) = 2−n , (b) f2(n) = n −log2 n are smaller than n −3 for all n > N .
A1. (a) N ≈ 133194, (b) N = 8.
Closure Properties of Negligible Functions
Fact. If f1(n) and f2(n) are negligible functions, then the following hold:
2. For any positive polynomial p, the function f4(n) = p(n) ⋅ f1(n) is negligible.
−n 1/3
Example. We have seen that 2 and n −log2 n are negligible functions.
1/3
From the theorem it follows that 2−n + n −log2 n is negligible and also
1/3
n 4 ⋅ 2−n is negligible.
Q2. Verify these by finding N such that each of the above functions is smaller than n −4 for all n > N .
Solving for Parameters Exercise
n 1/3(log2 n)
2/3
Q1. The best classical factoring algorithm requires a running time of about 2 clock cycles
to factor an n-bit number. Consider an attacker who has access to a 4GHz computer.
Estimate the size of the numbers that the attacker cannot factor for the next 100 years.
Let us find n for which the n-bit number can be factored within the next 100 years:
n 1/3(log2 n)
2/3
2 ≤ 3.1536 × 109 × 4 × 109 = 126144 × 1014
n 1/3 (log2 n)
2/3
≤ log2 126144 + 14 log2 10 = 16.945 + 46.507 = 63.452
n (log2 n) ≤ 255464.11
2
Solving for Parameters Exercise
n 1/3(log2 n)
2/3
Q1. The best classical factoring algorithm requires a running time of about 2 clock cycles
to factor an n-bit number. Consider an attacker who has access to a 4GHz computer.
Estimate the size of the numbers that the attacker cannot factor for the next 100 years.
loge n
A1. Continued. Let x = loge n . Then n = e x, log2 n =
loge 2
n (log2 n) ≤ 255464.11
2
x ≤ 7.649 ⟹ n ≤ 2098.5
For n > 2099, attacker cannot factor the n-bit number in 100 years.
Solving for Parameters Exercise
n 1/3(log2 n)
2/3
Q1. The best classical factoring algorithm requires a running time of about 2 clock cycles
to factor an n-bit number. Consider an attacker who has access to a 4GHz computer.
Estimate the size of the numbers that the attacker cannot factor for the next 100 years.
Q2. Let Π = (Enc, Dec) be a cipher defined over (𝒦, ℳ, 𝒞) with ℳ = {0,1}l .
Suppose that for Π, there exists an efficient (PPT) adversary ℬ that could predict 𝚙𝚊𝚛𝚒𝚝𝚢(m)
Q3. Consider the following permutation cipher Π = (Enc, Dec) defined over (𝒦, ℳ, 𝒞) where
For a key k ∈ 𝒦 and message m ∈ ℳ define Enck(m) to be the result of permuting the bits of m
Firstly, we recognize that randomness is the property, not of a particular bit string, but of
We'll say that a distribution D on {0,1}l is pseudorandom if the experiment in which a bit
The uniform distribution on l-bit strings is the distribution Ul where Ul(x) = 2−l for all x ∈ {0,1}l .
Definition: Let {Dn} be a sequence of distributions over p(n)-bit strings. {Dn} is pseudorandom if
for every probabilistic, polynomial-time algorithm A, there is a negligible function ϵ such that
We may think of 𝒜 as executing statistical tests in polynomial time. The sequence of distributions
{Dn} is pseudorandom if it passes all efficient statistical tests, i.e., it is infeasible (beyond
probability ϵ(n) ) for any polynomial-time algorithm to distinguish whether the bit string is sampled
Example A(x) = 1 if #0(x) − #1(x) ≤ 10 p(n), A(x) = 1 if max run of 0's in x is ≤ 2 log2 p(n) .
Tests for uniformity, consistency, frequency, compressability, Forward and backward Unpredictability.
data, and apply some processing to smooth this out and get uniform random bits.
a short, uniform seed s into a longer, pseudorandom output G(s) where | G(s) | = p( | s | ) > | s | .
Seed s
Output G(s)
Pseudorandom (number) generators (PRGs/PRNGs): Formal
Definition
Definition. Let p be a polynomial and let G be a deterministic polynomial-time algorithm such that
for any n and any input s ∈ {0,1}n, G(s) is a string of length p(n) .
1. Expansion: For every n it holds that p(n) > n . We call p the expansion factor of G .
2. Pseudorandomness: For any PPT algorithm D, there is a negligible function ϵ such that
where the first probability is over uniform choice of s ∈ {0,1}n and the randomness of D,
and the second is over uniform choice of r ∈ {0,1}p(n) and the randomness of D .
Pseudorandom (number) generators (PRGs/PRNGs): Points to
note
By definition, for a PRG G, no efficient attacker 𝒜 can distinguish whether it is given G(s)
(for uniform s of length n bits) or a uniform string y of length p(n) bits.
2n
Note however that G(s) itself is not uniform. The fraction of strings in the range of G is p(n) .
2
Many strings do not occur as outputs of G .
{0,1}n
Q . Suppose G : {0,1}n → {0,1}2n satisfies msb(G(s)) = 1 for 2/3 fraction of the s in {0,1}n .
Is G a PRG?
Pseudorandom Generator Exercise
(a) G′(x) = G(x)[0,…, n − 2] i.e., G′(x) drops the final bit of G(x) .
(a) G′(x) = G(x)[0,…, n − 2] i.e., G′(x) drops the final bit of G(x) .
A(a) Yes. G′ is a secure PRG. One can construct a distinguisher for G given a distinguisher for G′ . Why?
A(b) No. G′ is NOT a secure PRG. A distinguisher for G′ can output not random when the last bit is not 0.
A(c). Yes. G′ is a secure PRG. One can construct a distinguisher for G given a distinguisher for G′ .
Pseudorandom Generator Exercise
A(d) Yes. G′ is a secure PRG. One can construct a distinguisher for G given a distinguisher for G′ .
A distinguisher for G′ can output not random when the first n bits does not equal the last n bits.
In each case, understand how to construct the distinguisher, and to calculate the distinguishing probability.
Pseudorandom (number) generators (PRGs/PRNGs): Points to
note
In general, this is not known. If we could unconditionally prove that a particular PRG is secure,
We know particular examples of deterministic functions G called stream ciphers for which
We can also construct PRGs from weaker assumptions (that one-way functions exist)
which hold if, for instance certain problems like factoring are hard.
Linear Congruential Generator
The Linear Congruential Generator generates a sequence of pseudo-random numbers {Xn} via :
If the adversary knows parameters and one number, it can easily determine subsequent numbers.
Blum Blum Shub Generator
The Blum Blum Shub Generator is a cryptographically secure pseudo-random bit generator.
The Blum Blum Shub generator generates a sequence of pseudo-random bits Bi via :
s = 101355
Output Bi are the lsb of Xi .
Blum, L.; Blum, M.; Shub, M. (1986). "A Simple Unpredictable Pseudo-Random Number Generator"
SIAM Journal on Computing. Society for Industrial & Applied Mathematics (SIAM). 15 (2): 364–383.
Pseudo One-Time Pad
Pseudo One-Time Pad is a private-key encryption scheme built upon any pseudorandom generator.
Enc : Takes as inputs key k ∈ {0,1}n and message m ∈ {0,1}p(n), outputs the ciphertext
c := G(k) ⊕ m .
Dec : Takes as inputs key k ∈ {0,1}n and ciphertext c ∈ {0,1}p(n), outputs the message
m : G(k) ⊕ c .