Intro to Crypto

Lecture 1: How to define security?

Encrpytion and Decryption

The setup:

Let A\mathcal{A} be an abitrary but fixed set of symbols, which we call the alphabet.

  • The key space K\mathcal{K} is a set of strings over A\mathcal{A}.
  • The message space M\mathcal{M} is also a set of strings over A\mathcal{A}.
  • The ciphertext space C\mathcal{C} is also a set of strings over A\mathcal{A}.

We also have two functions:

  1. The encryption function:

E:K×MC,\mathfrak{E}: \mathcal{K} \times \mathcal{M} \longrightarrow \mathcal{C},

which takes as input a key kKk \in \mathcal{K} and a message mMm \in \mathcal{M}, and outputs a ciphertext cCc \in \mathcal{C}.

  1. The decryption function:

D:K×CM{},\mathfrak{D}: \mathcal{K} \times \mathcal{C} \longrightarrow \mathcal{M} \cup \{\bot\},

which takes as input a key kKk \in \mathcal{K} and a ciphertext cCc \in \mathcal{C}, and outputs a message mMm \in \mathcal{M} or the symbol \bot (which is pronounced bottom, and captures a failure signal, e.g, on a corrupt input).

The encrpytion scheme is said to be valid if for all (k,m)K×M(k,m) \in \mathcal{K} \times \mathcal{M}, it holds that:

D(k,E(k,m))=m\mathfrak{D}(k, \mathfrak{E}(k, m)) = m

A Secruity Definition

Once we have a proposal for a valid encryption/decryption scheme, we would like to know if it is a decent one: and in our context, we like schemes that can survive adverserial attacks: imagine someone snooping over the communication channel, and trying to learn the message from the ciphertext — we would like to make claims to the effect of “that won’t be possible”.

To formalize this, we have the notion of a security game, which is a game played between two players: a challenger and an adversary. The challenger is the one who sets up the game, and the adversary is the one who tries to break the scheme. Here’s what the game looks like:

  1. The challenger picks a key kKk \in \mathcal{K} uniformly at random and a picks a bit b{0,1}b \in \{0,1\} uniformly at random
  2. The adversary sends the challenger two messages m0m_0 and m1m_1.
  3. The challenger sends the ciphertext c=E(k,mb)c = \mathfrak{E}(k, m_b) to the adversary.
  4. The adversary outputs a bit bb'.
  5. The adversary wins if b=bb = b'.

Note that an adversary that outputs a bit in step 4 by tossing a coin (1 if H and 0 if T) wins this game with probability 1/21/2.

A self-respecting adversary will want to fare better, while a scheme worth its salt will not want to be vulnerable with respect to any adverseray, so we say that:

  • an adversary wins this game if they can win it with probability greater than half, and,
  • a scheme is secure if no adversary can win this game with probability greater than half.

Example: An Insecure Scheme

Consider a lazy encryption scheme that does not encrypt a message at all:

  • E(k,m)=m\mathfrak{E}(k,m) = m and
  • D(k,c)=c\mathfrak{D}(k,c) = c.

It is easy to see that there is an adversary who can win the security game defined above with probability 1, so this is not a terribly smart scheme. The same is true for schemes that rotate the message by a fixed amount (why?).

Example: An Secure Scheme

Assume the message space, key space, and ciphertext space are all nn-bit strings for some arbitrary but fixed choice of nn. Consider the following encryption scheme:

  • E(k,m)=km\mathfrak{E}(k,m) = k \oplus m and
  • D(k,c)=kc\mathfrak{D}(k,c) = k \oplus c.

It turns out that this scheme is secure, intuitively because for any ciphertext cc, there are two keys k1k_1 and k2k_2 which are such that:

  • D(k1,c)=m0\mathfrak{D}(k_1,c) = m_0, and
  • D(k2,c)=m1\mathfrak{D}(k_2,c) = m_1,

for any two messages m0m_0 and m1m_1, so there is no way for the adversary to reverse engineer the bit bb.

(Exercise: prove this formally.)

Example: Another Insecure Scheme

Assume the message space and ciphertext space are 2n2n-bit strings for some arbitrary but fixed choice of nn, and the key space is the set of all nn-bit strings. Consider the following encryption scheme:

  • E(k,m)=(kk)m\mathfrak{E}(k,m) = (k | k) \oplus m and
  • D(k,c)=(kk)c\mathfrak{D}(k,c) = (k | k) \oplus c,

where (ab)(a | b) denotes the concatenation of two strings.

It turns out that this scheme is not secure (why?).

A Stronger Secruity Definition

Consider the following extended security game:

  1. The challenger picks a key kKk \in \mathcal{K} uniformly at random and a picks a bit b{0,1}b \in \{0,1\} uniformly at random.
  2. The adversary sends the challenger two messages m00m_{00} and m01m_{01}.
  3. The challenger sends the ciphertext c0=E(k,m0b)c_0 = \mathfrak{E}(k, m_{0b}) to the adversary.
  4. The adversary sends the challenger two messages m10m_{10} and m11m_{11}.
  5. The challenger sends the ciphertext c1=E(k,m1b)c_1 = \mathfrak{E}(k, m_{1b}) to the adversary.
  6. The adversary outputs a bit bb'.
  7. The adversary wins if b=bb = b'.

As before, we say that:

  • an adversary wins this game if they can win it with probability greater than half, and,
  • a scheme is secure if no adversary can win this game with probability greater than half.

However, in the extended game, we have empowered the adversary to a point where no deterministic scheme can be secure in this stronger sense! Here’s why:

  • Suppose the adversary picks: m00=0nm_{00} = 0^n, m01=1nm_{01} = 1^n, m10=0nm_{10} = 0^n, m11=01n1m_{11} = 01^{n-1}.
  • Then the adversary returns 00 if c0c_0 and c1c_1 are identical, and 11 otherwise.

Note that this particular adversary wins with probability 1, no matter what E\mathfrak{E} and D\mathfrak{D} are.

What can we say about randomized schemes? Can they be secure in the extended setting?