Post · 15 min read· pp. 10–26

40 years of secret key exchange

(\def\FF{\mathbb{F}} \def\PP{\mathbb{P}} \def\bk#1{\lvert#1\rangle} \def\abs#1{\lvert#1\rvert} \def\Enc{\mathrm{Enc}} \def\Dec{\mathrm{Dec}} \def\Sig{\mathrm{Sig}} \def\Ver{\mathrm{Ver}})

40 years of secret key exchange

by Luca De Feo

Rentrée des Masters Jacques Hadamard

September 8-9, 2016. Paris Saclay.



The beginnings of public key cryptography


Cryptography, helping lovers since 2000 BC

O Romeo, Romeo! wherefore art thou Romeo? Deny thy father and refuse thy name; Or, if thou wilt not, be but sworn my love, And I’ll no longer be a Capulet.

Confidentiality: Has Tybalt seen the message?

Authenticity: Is the message really from Juliet?

Integrity: Is the message exactly what Juliet meant to send?

…and: Secret sharing, homomorphic encryption, multiparty computation, plausible deniability, anonimity, proofs of knowledge, proofs of work, …


Secret key (symmetric) cryptography

Romeo and Juliet have met in the Capulet’s orchard. Upon falling in love, they have agreed on a secret key S.

It was the nightingale, and not the lark, That pierced the fearful hollow of thine ear;                           ↓ S   Lw#zdv#wkh#qljkwlqjdoh#dqg#qrw#wkh#odun# Wkdw#slhufhg#wkh#ihduixo#kroorz#ri#wklqh#hdu                           ↓ S-1   It was the nightingale and not the lark That pierced the fearful hollow of thine ear

  • Known since the ancient times;

  • Widely used during war times, played a key role in WWII;

  • The cryptanalytic efforts of WWII gave birth to the modern computer (ever heard of Enigma, Alan Turing, Bletchley Park, Colossus, …)

  • With a little care, secret key cryptography achieves confidentiality, authenticity and integrity.


The birth of public key (asymmetric) cryptography

The modern day Romeo and Juliet have only met on Tinder. They want to share their most intimate secrets in a confidential way, but the Internet is fraught with pirates, hackers, governments, and tech-savvy Italian moms wanting to spy on their messages.

Can Romeo and Juliet establish a common secret by chatting on a public channel without having ever met before in person?


1976: New directions in cryptography

Our modern day Romeo and Juliet: W. Diffie and M. Hellman

We stand today on the brink of a revolution in cryptography. The development of cheap digital hardware has freed it from the design limitations of mechanical computing and brought the cost of high grade cryptographic devices down to where they can be used in such commercial applications as remote cash dispensers and computer terminals. In turn, such applications create a need for new types of cryptographic systems which minimize the necessity of secure key distribution channels and supply the equivalent of a written signature. At the same time, theoretical developments in information theory and computer science show promise of providing provably secure cryptosystems, changing this ancient art into a science.


The Diffie-Hellman key exchange protocol (abstract version)

Let GG be a finite cyclic group, noted multiplicatively, generated by an element g∈Gg∈G.

  • GG is abelian,
  • Let NN be the order of GG,
RomeoJuliet
Picks 0<a<N0<a<N at random;Picks 0<b<N0<b<N at random;
Computes A=gaA = g^a;Computes B=gbB = g^b;
—A→—A→
←B—←B—
Computes S=Ba=gbaS = B^a = g^{ba}Computes S=Ab=gabS = A^b = g^{ab}

Ok, SS is a common something. But is it a secret?

Lady Capulet is spying on Romeo and Juliet’s conversation:

  • She knows GG, NN and gg;
  • She sees AA and BB.

How can she recover SS?

Let’s see an example with G=Z/NZG=ℤ/Nℤ.


Hard problems

Let GG be a cyclic group of order NN.

Discrete logarithm

Let g,A∈Gg,A∈G, the discrete logarithm log⁡gA\log_g A is the unique integer 0≤a<N0≤a<N such that ga=Ag^a=A.

Discrete logarithm problem (DLP) : Given g,A∈Gg,A∈G, find log⁡gA\log_g A.

Computational Diffie-Hellman problem (CDH) : Given g,A,B∈Gg,A,B∈G, find SS such that (S = A^{\log_g B} = B^{\log_g A} = g^{(\log_g A)(\log_g B)}).

Security reductions

Obviously: CDH → DLP (if you can solve DLP, you can solve CDH);

Conjectured: DLP → CDH.


Computational security

We cannot hope discrete logarithm to be unsolvable for any group. But we can hope it to take VERY LOOONG to solve.

Cost of secret generation

Square-and-multiply exponentiation algorithm:

a↦ga=(g⎣a/2⎦⏟recursive call)2⋅ga mod 2a ↦ g^a = (\underbrace{g^{⎣a/2⎦}}_{\text{recursive call}})^2 · g^{a\bmod 2}

  • ⎡log⁡2N⎤⎡\log_2 N⎤ recursive calls;
  • one or two group operations at each call.

Total cost: O(log⁡N)O(\log N) group operations.

We say that DLP (or CDH) is hard in GG if no algorithm solves it in polynomial time in log⁡N\log N.

  • DLP is clearly not hard in (Z/NZ,+)(ℤ/Nℤ, +).
  • DLP is at worse exponential in log⁡N\log N (hint: test all exponents <N<N).
  • Advanced algorithms (Baby step-giant step, Pollard rho) solve DLP in O(N)O(\sqrt{N}).
  • By the Chinese remainder theorem, this can be reduced to O(p)O(\sqrt{p}), where pp is the largest prime factor of NN (Pohlig-Hellman).

And if you know a little about complexity theory:

  • DLP is in NP.
  • If P = NP, then DLP is not hard for any group.
  • Since we do not know whether P = NP, we do not know any group with hard DLP.

… But we can still conjecture that DLP is hard for some groups…


The classical Diffie-Helman protocol

Let qq be a prime, the modular integers Z/qZℤ/qℤ form a finite field, also written \FFq\FF_q.

Denote by \FFq∗\FF_q^* the multiplicative group of units of \FFq\FF_q.

That is all elements of \FFq\FF_q, except 00, with group operation given by multiplication.

  • \FFq∗\FF_q^* is cyclic of order q−1q-1;
  • A generator of \FFq∗\FF_q^* can be computed easily using Lagrange’s theorem.

If q−1q-1 has a large prime factor, the DLP in \FFq∗\FF_q^* seems to be hard!

Fq∗\mathbb{F}_q^*" target="_blank" rel="noopener noreferrer">An example.


Capulet in the middle

It is easy to prove that if CDH is hard, then the Diffie-Hellman key exchange is secure against passive adversaries.

However, if Lady Capulet can intercept messages on Tinder and manipulate them…


RomeoLady CapuletJuliet
Picks 0<a<N0<a<N at random;Picks 0<c<N0<c<N at random;Picks 0<b<N0<b<N at random;
Computes A=gaA = g^a;Computes C=gcC = g^c;Computes B=gbB = g^b;
—A→—A→—C→—C→
←C—←C—←B—←B—
Computes S=Ca=gcaS = C^a = g^{ca}Computes S=Ac=gacS = A^c = g^{ac}
Computes S′=Bc=gbcS' = B^c = g^{bc}Computes S′=Cb=gcbS' = C^b = g^{cb}
⇐S⇒⇐S⇒⇐S′⇒⇐S'⇒

Public key encryption

Instead of an ephemeral key, Juliet has a long term secret key anyone can use to send her private message.

Public key encryption system

Key pair : A pair (Kp,Ks)(K_p, K_s) (public key, secret key), : KpK_p is publicly known (published on Juliet’s Tinder profile).

Encryption algorithm \Enc(Kp,m)\Enc(K_p, m) : Inputs: public key KpK_p and a message mm; : Output: a cyphertext cc.

Decryption algorithm \Dec(Ks,m)\Dec(K_s, m) : Inputs: secret key KsK_s and a cyphertext c=\Enc(Kp,m)c=\Enc(K_p, m); : Output: the message mm.

Security properties:

  • Only the owner of KsK_s can decrypt cyphertexts encrypted with KpK_p.
  • It is easy to derive a key exchange protocol from a PK encryption one.
  • The other direction is harder.

First ever encryption protocol: RSA (Rivest, Shamir, Adleman 1977)

  • Based on hardness of integer factorization;
  • Already known to GCHQ by 1973.

From Diffie-Hellman to PK encryption: the El Gamal protocol (1985)

Parameters
  • Finite field \FFq\FF_q;
  • Generator g∈\FFq∗g∈\FF_q^*;
Keys
  • Secret key: random 0<a<q−10<a<q-1;
  • Public key: Kp=gaK_p = g^a;

Encryption

Input: Public key KpK_p, a message m∈\FFq∗m∈\FF_q^*;

  1. Pick random 0≤b<q−10≤b<q-1;
  2. Compute c1=gbc_1 = g^b;
  3. Compute s=(Kp)bs = (K_p)^b (shared secret);
  4. Compute c2=m⋅sc_2 = m·s;

Output: The cyphertext (c1,c2)(c_1, c_2).

Decryption

Input: Secret key aa, a cyphertext (c1,c2)∈\FFq∗×\FFq∗(c_1,c_2)∈\FF_q^* × \FF_q^*;

  1. Compute s=c1as = c_1^a (shared secret);
  2. Compute m=c2⋅s−1m = c_2 · s^{-1};

Output: The message mm.

CDH hard ⇒ El Gamal is secure


Signatures

But how does Juliet know that the message is really from Romeo?

Public key signature system

Key pair : A pair (Kp,Ks)(K_p, K_s) (public key, secret key), : KpK_p is publicly known (published on Romeo’s Tinder profile).

Signature algorithm \Sig(Ks,m)\Sig(K_s, m) : Inputs: secret key KsK_s and a message mm; : Output: a signature ss.

Verification algorithm \Ver(Kp,m,s)\Ver(K_p, m, s) : Inputs: public key KpK_p, a message mm, a signature ss; : Output: OK if s=\Sig(Ks,m)s = \Sig(K_s, m), FAIL otherwise.

Security property:

  • Only the owner of KsK_s can sign messages for KpK_p.
  • Security proofs for signature protocols are usually much more complicated than for encryption protocols. We will not discuss them.

Signatures are hard:

  • No automatic way to obtain a signature algorithm from PK encryption;
  • RSA signature, introduced together with RSA;
  • Signatures from Diffie-Hellman: Schnorr signature (1988), DSA (1991).

Schnorr signatures

Parameters
  • Finite field \FFq\FF_q;
  • Generator g∈\FFq∗g∈\FF_q^*;
  • A hash function H:{0,1}∗→\FFq∗H: \{0,1\}^* → \FF_q^*;
Keys
  • Secret key: random 0<a<q−10<a<q-1;
  • Public key: Kp=gaK_p = g^a;

Signature

Input: Secret key aa, a message m∈{0,1}∗m∈\{0,1\}^*;

  1. Pick random 0≤b<q−10≤b<q-1;
  2. Compute r=gbr = g^b;
  3. Compute e=H(m∥r)e = H(m \| r);
  4. Compute s=b−a⋅es = b - a·e;

Output: The signature (s,e)(s, e).

Verification

Input: Public key KpK_p, a message mm, a signature (s,e)(s, e);

  1. Compute r=(Kp)e⋅gsr = (K_p)^e · g^s;
  2. Compute e′=H(m∥r)e' = H(m \| r);

Output: OK if e=e′e = e', FAIL otherwise.


Final remarks

  • A weaker form of signatures gives authentication protocols. These can be combined with key exchange protocols to obtain a key exchange secure in presence of active adversaries.
  • All along we have assumed that we trust Tinder to correctly present Romeo and Juliet’s public keys. But what if Lady Capulet manipulates Tinder? Distributing public keys in a safe manner requires a trust infrastructure (Public Key Infrastructure (PKI), web of trust, …). This is a complex subject, out of the scope of this course.


Modern day key exchange

Generic attacks on DLP

Let GG be a cyclic group of order NN, let gg be a generator.

DLP: Given h=gah = g^a, find aa.

Baby-step/giant-step, Pollard Rho

Idea: look for collisions of the form

gx=hy,g^x = h^y,

then a=x/ymod  Na = x/y \mod N.

  • Baby-step/giant-step: time/memory tradeoff, O(N)O(\sqrt{N}) time and memory;
  • Pollard Rho: random walk, based on birthday paradox, O(N)O(\sqrt{N}) time, constant memory.
Pohlig-Hellman

Suppose N=p1⋅p2⋯pnN = p_1·p_2 \cdots p_n, by the Chinese remainder theorem

G≃Z/NZ=Z/p1Z×Z/p2Z×⋯xZ/pnZ,G ≃ ℤ/Nℤ = ℤ/p_1ℤ × ℤ/p_2ℤ × \cdots x ℤ/p_nℤ,

  • Solve a discrete logarithm in each of Z/piZℤ/p_iℤ (using BSGS, Pollard Rho, …),
  • Lift the solution using CRT.

Complexity: O(p)O(\sqrt{p}), where pp is the largest factor of NN.


Sub-exponential algorithms for finite fields

LN(α,c)=exp⁡(clog⁡(N)α⋅log⁡log⁡(N)1−α)L_N(α,c) = \exp(c\log(N)^α · \log\log(N)^{1-α})

  • LN(0,⋅)L_N(0,·) polynomial complexity,
  • LN(1,⋅)L_N(1,·) exponential complexity.
Index calculus
  • First discovered by Gauss;
  • Based on the concept of smooth elements.

Smooth element

We say that an integer is BB-smooth if it is the product of primes <B<B.

General index calculus

Input: g,h∈\FFq∗g,h∈\FF_q^*, Output: log⁡g(h)\log_g(h).

  1. Choose a smoothness basis B={x  ∣  x<B}\mathcal{B} = \{x\;\vert\; x<B\};

  2. Choose a field generator b∈Bb∈B;

  3. Compute the discrete logs base bb of all elements of B\mathcal{B}:

    • Collect enough relations of the form

      ∏(bi)ei=1;\prod (b_i)^{e_i} = 1;

    • Put them in a matrix, use linear algebra to find each discrete log;

  4. Rewrite gg and hh as products of elements of B\mathcal{B};

Output: log⁡g(h)\log_g(h).

Index calculs variants
  • Classical: B∼LN(1/2,⋅)B\sim L_N(1/2,·), complexity LN(1/2,⋅)L_N(1/2,·).
  • Number Field Sieve: B∼LN(1/3,⋅)B\sim L_N(1/3,·), complexity LN(1/3,⋅)L_N(1/3,·); suitable for \FFq\FF_q with qq prime or a small prime power.
  • Function Field Sieve: B∼LN(1/3,⋅)B\sim L_N(1/3,·), complexity LN(1/3,⋅)L_N(1/3,·); suitable for \FFq\FF_q with a large prime power.
  • Quasi-polynomial (Barbulescu, Gaudry, Joux, Thomé 2011): B∼(log⁡N)O(1)B\sim (\log N)^{O(1)}, complexity O((log⁡N)log⁡log⁡N)O((\log N)^{\log\log N}), suitable for \FFq\FF_q of very small characteristic.

Secrity levels

It is usually assumed that unfeasible amounts of computation start at ∼280\sim 2^{80} elementary operations.

For good measure

  • A CPU @1GHz can do 2302^{30} elementary ops/sec;
  • Amazon EC2 cloud is reported to have delivered (in 2013) approx 2502^{50} ops/sec at a rate of 0.50.5 $/sec;
  • The distributed Bitcoin infrastructure delivers (in 2016) more than 2602^{60} ops/sec;
  • Exascale computing (2602^{60} ops/sec) is expected to arrive by 2018.
Security levelIdealDLP over \FFp\FF_pElliptic curve DLPNSA recommendation
801601024160
961921536192
1122242048224
1282563072256SECRET
1923847680384TOP SECRET
25651215360512

Key lenghts (in bits) for given security level.


Elliptic curves

Projective space

Let kk be a field, the projective space \PP2(k)\PP^2(k) is the set of all lines in k3k^3 passing through the origin.

Equivalently, it is the set of triples

(X:Y:Z)≠(0:0:0),(X:Y:Z) ≠ (0:0:0),

up to the equivalence relation

(X:Y:Z)∼(λX:λY:λZ).(X:Y:Z) \sim (λX:λY:λZ).


Elliptic curves

An elliptic curve over a field kk (of characteristic >3>3) is the set of projective solutions of an equation

E  :  Y2Z=X3+aXZ2+bZ3,E \;:\; Y^2Z = X^3 + aXZ^2 + bZ^3,

with a,b∈ka,b\in k, with a distinguished point (the point at infinity (0:1:0)(0:1:0)).


Group law

The chord and tangent law

Let’s work out some examples


Hasse’s theorem

Theorem

Let E/kE/k be an elliptic curve defined over a finite field kk, then the number #E(k)\#E(k) of rational points of EE is bounded by

\abs#E(k)−q+1≤2q.\abs{\#E(k) - q + 1} ≤ 2\sqrt{q}.

Bonus
  • All cardinalities in the interval are attained;
  • There tend to be more curves toward the middle (see Sato/Tate conjecture).
ECDLP
  • Choose \FFq\FF_q with e.g. q∼2256q\sim 2^{256};
  • Take curves at random;
  • Use the Schoof-Elkies-Atkin point counting algorithm to compute #E(\FFq)\#E(\FF_q);
  • Stop once you have found a curve with prime order.


Key exchange in a post-quantum world

▶ Video: https://upload.wikimedia.org/wikipedia/commons/transcoded/4/49/Babbage_Engine_Demonstration_pt._3.webm/Babbage_Engine_Demonstration_pt._3.webm.480p.webm

key frames


History of computers

Computer sciencePhysics
1642Blaise Pascal’s mechanical calculator
1687Isaac Newton’s Philosophiæ Naturalis Principia Mathematica
1821André Ampère’s theory of electrodynamics
1822Charles Babbage’s difference engine
1837Charles Babbage’s analytical engine
1842Ada Lovelace writes the first computer program
1854Lord Kelvin’s On the Dynamical Theory of Heat
1871Maxwell’s and Clausius statistical thermodynamics
1873James C. Maxwell’s Treatise on Electricity and Magneitsm
1900Max Planck’s black body radiation law
1905Albert Einstein’s special relativity
1911Niels Bohr’s atomic model
1912Henri Poincaré Sur la théorie des quanta
1916Albert Einstein’s general relativity
1926Erwin Schrödinger’s equation.
1927Werner Heisenberg’s uncertainity principle
1935Einstein-Podolsky-Rosen quantum entanglement (spooky action at a distance)
1939Konrad Zuse’s electromechanical computers
1943Max Newman’s Colossus
1946ENIAC
1947Transistors
1952Integrated circuits
1964John S. Bell’s inequalties
1980Quantum computing (Yuri Manin, Richard Feynman, …)
1994Peter Shor’s factoring algorithm
2???First quantum computer

Quantum computing

Classical computers
  • Elementary states (bits): either 0 or 1;
  • Elementary transformations (boolean gates): AND, OR, NOT, …;
  • Information can be copied at will.
Quantum computers
  • Quantum states (qubits): a mix of 0 and 1;
  • Elementary transformations (quantum gates), reversible: Hadamard, CNOT, Pauli X, Y and Z, CNOT, Toffoli, Fredkin, …;
  • Quantum information collapses to a classical state when read;
  • No-cloning theorem: information cannot be copied at will.

Quantum cats


Qubit

Mathematically
  • Just an element of C2/Rℂ^2/ℝ.

  • Usually represented on a basis \bk0,\bk1\bk{0}, \bk{1}:

    ∣φ〉=α\bk0+β\bk1,α,β∈C|φ〉 = α\bk{0} + β\bk{1},\qquad α,β ∈ ℂ

    where \absα2+\absβ2=1\abs{α}^2 + \abs{β}^2=1.

  • When observed (measured), we only obtain a pure state \bk0\bk{0}, or \bk1\bk{1} (with probabilities \absα2\abs{α}^2 and \absβ2\abs{β}^2, resp.).

Phisically
  • an atom with two possible energy states \bk0\bk{0} and \bk1\bk{1},
  • a photon with two possible polarizations,
  • …

Entanglement

Two or more qubits can become entangled, also called a superposition state.

Mathematically
  • Qubits exists as tensor products of states, rather than as cartesian products,

  • e.g., the possible states for two qubits are

    ∣φ〉=α\bk0⊗\bk0+β\bk0⊗\bk1+γ\bk1⊗\bk0+δ\bk1⊗\bk1,α,β,γ,δ∈C|φ〉 = α\bk{0}⊗\bk{0} + β\bk{0}⊗\bk{1} + γ\bk{1}⊗\bk{0} + δ\bk{1}⊗\bk{1},\qquad α,β,γ,δ ∈ ℂ

    where \absα2+\absβ2+\absγ2+\absδ2=1\abs{α}^2+\abs{β}^2+\abs{γ}^2+\abs{δ}^2 = 1.

  • The dimension of the state space grows exponentially with the number of qubits!

  • Measuring collapses the state onto a classical one.

Spooky action at a distance (EPR)

  • Entanglement can be carried over long distances;
  • Tested experimentally over hundreds of km;
  • …very hard to maintain for a long time even locally, though.

Quantum circuits

Quantum gates
  • Unitary matrices acting over the state space.
  • Reversible, because physics is (at small scale, at least).
  • Small set of elementary gates (similar to AND, OR, …).
Quantum circuits
  • Networks of elementary quantum gates;
  • Reversible: no measuring happens before the very end.

The most dangerous quantum circuit ever

Quantum Fourier transform (QFT)

  • Computes a Fourier transform of a quantum state,
  • Circuit size polynomial in the number of qubits → logarithmic in the size of the state space.

Peter Shor’s period-finding algorithm
  • Finds the period of a function Z/NZ→Z/NZℤ/Nℤ → ℤ/Nℤ, in O(log⁡N)O(\log N) quantum steps;
  • Immediate application to DLP;
  • Classical reduction from Integer factoring.

RSA is dead. Diffie-Hellman is dead

Or is it?


Post-quantum cryptography

Slides at http://defeo.lu/talks/yacc-27-09-12.pdf



References

  1. W. Diffie, M. Hellman, New Directions in Cryptography. IEEE transactions on Information Theory, 1976.
  2. R.L. Rivest, A. Shamir, L. Adleman, A method for obtaining digital signatures and public-key cryptosystems Communications of the ACM, 1978.
  3. T. El Gamal, A public key cryptosystem and a signature scheme based on discrete logarithms. Advances in cryptology, 1984.
  4. C.P. Schnorr, Efficient signature generation by smart cards. Journal of cryptology, 1991.
  5. A. Joux, Algorithmic cryptanalysis. CRC Press, 2009.
  6. R. Barbulescu, P. Gaudry, A. Joux, E. Thomé, A heuristic quasi-polynomial algorithm for discrete logarithm in finite fields of small characteristic. EuroCrypt,
  7. S. Galbraith, Mathematics of Public Key Cryptography. Cambridge University Press, 2012.
  8. M.A. Nielsen, I.L. Chuang, Quantum Computation and Quantum Information. 10th Anniversary Edition. Cambridge University Press, 2011.
  9. A. Rostovtsev, A. Stolbunov, Public-Key Cryptosystem Based on Isogenies. IACR Cryptology ePrint Archive, 2006.
  10. D. Jao, L. De Feo, Towards quantum-resistant cryptosystems from supersingular elliptic curve isogenies International Workshop on Post-Quantum Cryptography, 2011.
  11. L. De Feo, D. Jao, J. Plût, Towards quantum-resistant cryptosystems from supersingular elliptic curve isogenies. Journal of Mathematical Cryptology, 2014.