TCS: Pseudorandomness and Private-Key Encryption

Pseudorandomness and Private-Key Encryption

Private-Key Encryption

This encryption(加密) problem is starting form the transmission question: two people need to transmit information while avoiding others to know the content.
The resolution is to maintain a ‘key’ kk by two people and one can use kk to encrypt information while the other can use it to decrypt

Validity

A pair of polynomial-time computable functions (Enc,Dec)(\text{Enc}, \text{Dec}) is a valid private key encryption scheme if for every nNn\in \mathbb{N}, k{0,1}nk\in \{0, 1\}^{n},and xx, we have

Dec(k,Enc(k,x))=x \text{Dec}(k, \text{Enc}(k, x)) = x

And we have the length of the ciphertext(密文) is no less than that of the plaintext, written as:

lc(n)lp(n)l_{c}(n) \geq l_{p}(n)

Security

We need to define the security with following assumption:

A cryptosystem should be secure even if everything about the system, except the key, is public knowledge.

Due to this assumption, the kk must be generated randomly.

So, let’s define the security:

A valid encryption scheme (Enc,Dec)(\text{Enc}, \text{Dec}) with plaintext length l()l(\cdot) is perfectly secret if for every nNn\in \mathbb{N} and plaintexts x0,x1{0,1}l(n)x_{0}, x_{1} \in \{0, 1\}^{l(n)}, the following two distributions Y0Y_{0}and Y1Y_{1} over {0,1}\{0, 1\}^{*} are identical:
YiY_{i} is obtained by sampling kk and outputting Enc(k,xi)\text{Enc}(k, x_{i}) for i=0,1i = 0, 1.

Definition Analysis

We have a secrecy experiment as follows:

  1. Sample k{0,1}nk \in \{0, 1\}^{n}
  2. Adversary A\mathcal{A} outputs x0,x1x_{0}, x_{1} given input 1n1^{n}
  3. Randomly choose bb and send y=Enc(k,xb)y = \text{Enc}(k, x_{b}) to A\mathcal{A}
  4. A\mathcal{A} returns b{0,1}b'\in\{0, 1\}
  5. If b=bb = b', A\mathcal{A} wins

We can prove A\mathcal{A} has at most 12\frac{1}{2} probability to succeed under perfectly secret.

P(Y=yb=i)=P(Yi=y)=p(y)\begin{align*} P(Y = y\,|\, b = i) &= P(Y_{i} = y) = p(y)\end{align*}

And P(Y=y)=p(y)P(Y = y) = p(y) due to YY is perfect, so:

P(Y=y,b=i)=P(b=i)P(Y=yb=i)=P(b=i)p(y)=P(b=i)P(Y=y)\begin{align*} P(Y = y, b = i) &= P(b = i)P(Y = y \,|\, b = i) \\ &= P(b = i)p(y) \\ &= P(b = i)P(Y = y)\end{align*}

This means YY is independent to bb, so A\mathcal{A} cannot improve its probability to win by getting yy

Construction

Give the One-time pad construction:

lp(n)=lc(n)=nEnc(k,x)=xkDec(k,c)=kc\begin{align*} l_{p}(n) = l_{c}&(n) = n \\ \text{Enc}(k, x) &= x \oplus k \\ \text{Dec}(k, c) &= k \oplus c\end{align*}

In this construction, we have one glaring dis advantage, that is the kk has the same length of plaintext!
This is necessary for perfect secrecy:

For every perfectly secret encryption scheme, the length function lp(n)l_{p}(n) satisfies lp(n)nl_{p}(n)\leq n

Computational Secrecy and PRG

The long kk is unadorable in reality. So we use computational secrecy instead.
An encryption scheme is computationally secret if no probabilistic polynomial-time(PPT) algorithms can break it.

Let Enc,Dec\text{Enc}, \text{Dec} be a valid encryption scheme. The scheme is computationally secret if, for every PPT adversary algorithm A\mathcal{A} in the secrecy experiment, there is negligible function negl\text{negl} such that

P(A succ)12+negl(n) P(\mathcal{A} \text{ succ}) \leq \frac{1}{2} + \text{negl}(n)

where the probability is taken over the randomness of A\mathcal{A} and the experiment.

Pseudorandom Generators

Definition:

A cryptographic pseudorandom generator (PRG) with stretch l()l(\cdot) is a PPT computable function G:{0,1}{0,1}G: \{0, 1\}^{*} \to \{0, 1\}^{*} such that:

  1. nN\forall \, n\in \mathbb{N} and s{0,1}ns\in \{0, 1\}^{n}, G(s)=l(n)|G(s)| = l(n)
  2. For any poly-algorithm A\mathcal{A}, s{0,1}ns\in \{0, 1\}^{n} and r{0,1}l(n)r\in \{0, 1\}^{l(n)}:

    P(A((G(s)))=1)P(A((r))=1)=negl(n) |{P (\mathcal{A}((G(s))) = 1) - P (\mathcal{A}((r)) =1)}| = \text{negl}(n)

Intuitively, this means we can get the difference between output of PRG G()G(\cdot) and a actual random output rr in a negligible probability.

Its existance is obtained by the cryptographic PRG conjecture: PRG with l(n)=naaNl(n) = n^{a}\quad \forall a\in\mathbb{N} exists.

If the cryptographic PRG conjecture is true, then computationally secret encryption exists for l(n)naaNl(n) \geq n^{a}\quad \forall a\in\mathbb{N}

Enc(k,x)=xG(k)Dec(c,k)=cG(k)\begin{align*} \text{Enc}(k, x) &= x \oplus G(k) \\ \text{Dec}(c, k) &= c \oplus G(k)\end{align*}

This can be proved to be computation secret by contradiction proof, which is to construct a adversary for PRG by the assuming contradiction.

CPA Security and PRF

Choose Plaintext Attack (CPA)

The CPA experiments is similar to secrecy experiments, while A\mathcal{A} can interact freely with Enc(k,)\text{Enc}(k, \cdot) as a black-box.

An encryption scheme (Enc,Dec)(\text{Enc}, \text{Dec}) is CPA-secure if, for all PPT adversary A\mathcal{A}, there exists a negligible function negl\text{negl} such that

P(A succ)12+negl(n) P(\mathcal{A} \text{ succ}) \leq \frac{1}{2} + \text{negl}(n)

All CPA-secure encryption scheme must be probabilistic otherwise A\mathcal{A} can query all Enc(k,x)\text{Enc}(k, x) to get ciphertexts and compare.

Pseudorandom Functions (PRF)

Consider a keyed family of functions: Fk:{0,1}{0,1}F_{k}: \{0, 1\}^{*} \to \{0, 1\}^{*}, then we can define PRF as follows:

Let FkF_{k} be a keyed family of functions that is efficient and length-preserving. We say FkF_{k} is a pseudorandom function if, for all PPT distinguishers D\mathcal{D}, there exists a negligible function negl\text{negl} such that:

P(DFk()(1n)=1)P(Dfn()(1n)=1)negl(n) |{P \bigl( D^{F_k(\cdot)}(1^n) = 1 \bigr) - P \bigl( D^{f_n(\cdot)}(1^n) = 1 \bigr)}| \le \text{negl}(n)

where k{0,1}nk\gets\{0, 1\}^{n} is chosen uniformly at random and fnf_{n} is chosen uniformly from the set of functions mapping nn-bit strings to nn-bit strings.

Intuitively, this means we can get the difference between PRF Fk()F_{k}(\cdot) and a actual random funtions ff in a negligible probability.

PRF => CPA-secure Encryption

Let FF be a PRF. Define a CPA-secuee private-key encryption scheme for messages of length nn as follows:

  1. Enc(k,x)=r,Fk(r)x\text{Enc}(k, x) = \langle r, F_{k}(r)\oplus x \rangle
  2. Dec(k,r,s)=Fk(r)s\text{Dec}(k, \langle r, s\rangle) = F_{k}(r) \oplus s

In this r{0,1}nr\gets\{0, 1\}^{n} is randomly chosen.

Proof is as follows, we use contradiction-proof and construct a contradiction to PRF with assumption.

Consider above scheme as Π=(Enc,Dec)\Pi = (\text{Enc}, \text{Dec}) and the similar scheme Π~=(Enc~,Dec~)\widetilde{\Pi} = (\widetilde{\text{Enc}}, \widetilde{\text{Dec}}) in which we replace FkF_{k} with an actual random function.

Assume that Π\Pi is not CPA-secure, which means there exists an A\mathcal{A}:

P(AΠ succ)12+1poly(n)P(\mathcal{A}_{\Pi}\text{ succ}) \geq \frac{1}{2} + \frac{1}{\text{poly}(n)}

Let rcr_{c} represents the randomness used in encrypting xx, while r1,,rqr_{1}, \dots, r_{q} represents the q(n)=poly(n)q(n) = \text{poly}(n) randomness used when A\mathcal{A} queries to the oracle Enc\text{Enc}.
Then we can argue that:

P(AΠ~ succ)12+negl(n)P(\mathcal{A}_{\widetilde{\Pi}}\text{ succ}) \leq \frac{1}{2} + \text{negl}(n)

We can argue this according to whether rc{r1,,rq}r_{c} \in \{r_{1},\dots ,r_{q}\}

  1. If rc{r1,,rq}r_{c} \in \{r_{1},\dots ,r_{q}\}, then A\mathcal{A} can actually get rcr_{c} as we contain it in the ciphertext. So A\mathcal{A} can always succeed in this case.But this case has a negligible probability q(n)2n\frac{q(n)}{2^{n}} to appear.
  2. If rc{r1,,rq}r_{c} \notin \{r_{1},\dots ,r_{q}\}, then the encryption is like a perfect OTP as we cannot get any information about the random function ff. So A\mathcal{A} has a probability of 12\frac{1}{2} to win.

So, we have that:

P(AΠ~ succ)=P(AΠ~ succ)P()+P(AΠ~ succ)P()q(n)2n+12=12+negl(n)\begin{align*}P(\mathcal{A}_{\widetilde{\Pi}}\text{ succ}) &= P(\mathcal{A}_{\widetilde{\Pi}}\text{ succ}\,|\in)P(\in) + P(\mathcal{A}_{\widetilde{\Pi}}\text{ succ}\,|\notin)P(\notin) \\&\leq \frac{q(n)}{2^{n}} + \frac{1}{2} = \frac{1}{2} + \text{negl}(n)\end{align*}

Define the distinguisher D\mathcal{D}, who has an orecal O\mathcal{O}, as follows:

  1. Run A(1n)\mathcal{A}(1^{n}), for each oracle query of A\mathcal{A} with xx, do:
    1. Choose r{0,1}nr\gets \{0, 1\}^{n}
    2. return r,O(r)x\langle r, \mathcal{O}(r)\oplus x\rangle to A\mathcal{A}
  2. When A\mathcal{A} gives D\mathcal{D} two string x0,x1x_{0}, x_{1}, randomly choose a bit bb and:
    1. Choose r{0,1}nr\gets \{0, 1\}^{n}
    2. return r,O(r)xb\langle r, \mathcal{O}(r)\oplus x_{b}\rangle to A\mathcal{A}
  3. Answer A\mathcal{A} as Step 1 until A\mathcal{A} gives an output bb'. Then we output 11 if b=bb' = b otherwise 00.

Actually, this distinguisher is simulating the CPA-experiment. So:

P(DFk()(1n)=1)=P(AΠ succ)P(Df()(1n)=1)=P(AΠ~ succ)\begin{align*}P(\mathcal{D}^{F_{k}(\cdot)}(1^{n}) = 1) &= P(A_{\Pi}\text{ succ}) \\P(\mathcal{D}^{f(\cdot)}(1^{n}) = 1) &= P(A_{\widetilde{\Pi}}\text{ succ})\end{align*}

This means that:

P(DFk()(1n)=1)P(Df()(1n)=1)=P(AΠ succ)P(AΠ~ succ)1poly(n)negl(n)1poly(n)\begin{align*}&\quad |P(\mathcal{D}^{F_{k}(\cdot)}(1^{n}) = 1) -P(\mathcal{D}^{f(\cdot)}(1^{n}) = 1)| \\&= |P(\mathcal{A}_{\Pi}\text{ succ}) - P(\mathcal{A}_{\widetilde{\Pi}}\text{ succ})| \\&\geq |\frac{1}{\text{poly}(n)} - \text{negl}(n)| \geq \frac{1}{\text{poly}(n)}\end{align*}

This is contradict to that FkF_{k} is PRF!