Key exchange secure against eavesdroppers #
A two-party key-exchange protocol is described here by the law of its honest execution: the
transcript of messages that an eavesdropper sees, the key output by Alice and the key output by
Bob. Keys may live in a set named by the transcript, such as the group chosen in Diffie–Hellman,
so the key type is a family K : T → Type. The protocol is correct when the two keys agree on
every execution.
Security against a passive eavesdropper ([KL20], Section 11.3, Definition 11.1,
p. 392; compare the session-key indistinguishability remark in [BS23], Section 10.1,
p. 400) compares a real experiment, in which the adversary receives the view made of the transcript
and Alice's key, with an ideal experiment, in which the view pairs the transcript with an
independently drawn ideal key. Saying that an adversary guesses a hidden uniform bit with
probability at most 1 / 2 + negl(n) is the same as requiring negligible advantage between the
real and the ideal experiment. Both experiments are "draw a view, then run the eavesdropper on it"
(Game.withSetup), for the view laws realView and idealView of an execution law. The ideal key
may depend on the transcript through idealKey : ℕ → (t : T) → PMF (K t); Definition 11.1 draws a
uniform n-bit word (EavSecureBits), while [KL20], Theorem 11.3 (p. 394, locator not
verified) uses a uniform element of the group named in the transcript (dhIdealKey).
Eavesdroppers are typed: an Eavesdropper T K receives the security parameter and a View T K.
Encodings appear only in its efficiency predicate Eavesdropper.IsPPT, which reads the view
through encView, and in encOutcome for certifying honest execution programs.
We formalize:
- the Diffie–Hellman protocol ([BS23], Section 10.4.1, Figure 10.2, pp. 407–408;
[KL20], Construction 11.2, pp. 392–393, locator not verified) over a
PrimeOrderGroupFamily, in two forms:- the fair-coin execution
dhExecutionProband protocoldhKeyExchangeProb, whose parties sample their exponents withPrimeOrderGroupFamily.sampleExp(isPPTOn_dhExecutionProb), always agree on the shared key (dhKeyExchangeProb_correct), stay within statistical distance2 / 2 ^ nof exact-uniform execution (advantage_bind_dhKeyExchangeProb_le), satisfy the explicit4 / 2 ^ npassive-eavesdropping boundadvantage_eavGame_dhKeyExchangeProb_le, and areEavSecureagainstdhIdealKeyunderDDH(DDH.dhKeyExchangeProb_eavSecure, [KL20], Theorem 11.3, p. 394, locator not verified; registration pending source check, #5657); - the ideal-sampling execution
dhExecutionand protocoldhKeyExchange, whose parties draw exponents fromPMF.uniformOfFintype (ZMod q), giving exact game identities withddhRealGameandddhRandomGameviadhEavToDDHand the ideal-sampling stepDDH.dhKeyExchange_eavSecure_idealconsumed byDDH.dhKeyExchangeProb_eavSecure;
- the fair-coin execution
- the man-in-the-middle attack of [KL20], Exercise 11.3 (p. 399): at a fixed group, an active adversary that replaces both public shares shares Alice's key with Alice and Bob's key with Bob, while each party's view has exactly the law of the eavesdropper's view of an honest execution;
- the protocol of [KL20], Exercise 11.4 (p. 400), built from one-time XOR masks: Alice and Bob output the same key, yet the XOR of the three transcript words is the key, so the protocol is not secure against eavesdroppers.
Honest-party efficiency is unbundled from KeyExchange; for dhExecutionProb, uniform strict PPT
efficiency on (1ⁿ, d) (or on 1ⁿ along a polynomial-time group schedule) is proved separately in
isPPTOn_dhExecutionProb.
Main definitions #
Cslib.Crypto.KeyExchange,Cslib.Crypto.KeyExchange.Outcome,Cslib.Crypto.KeyExchange.encOutcome: protocols as honest-execution laws and outcome encodings.Cslib.Crypto.KeyExchange.View,Cslib.Crypto.KeyExchange.encView,Cslib.Crypto.KeyExchange.Eavesdropper,Cslib.Crypto.KeyExchange.Eavesdropper.IsPPT: typed eavesdroppers and their efficiency on encoded views.Cslib.Crypto.KeyExchange.realView,Cslib.Crypto.KeyExchange.idealView,Cslib.Crypto.KeyExchange.realGame,Cslib.Crypto.KeyExchange.idealGame,Cslib.Crypto.KeyExchange.EavSecure,Cslib.Crypto.KeyExchange.EavSecureBits: security against eavesdroppers ([KL20], Definition 11.1).Cslib.Crypto.PrimeOrderGroupFamily.DHTranscript,Cslib.Crypto.PrimeOrderGroupFamily.dhExecutionProb,Cslib.Crypto.PrimeOrderGroupFamily.dhKeyExchangeProb,Cslib.Crypto.PrimeOrderGroupFamily.dhExecution,Cslib.Crypto.PrimeOrderGroupFamily.dhKeyExchange,Cslib.Crypto.PrimeOrderGroupFamily.dhIdealKey: the fair-coin and ideal-sampling Diffie–Hellman protocols and their group-element ideal key ([KL20], Construction 11.2, Theorem 11.3, locators not verified).Cslib.Crypto.PrimeOrderGroupFamily.dhEavToDDH: the reduction to DDH.Cslib.Crypto.PrimeOrderGroupFamily.dhMitmExecution: the man-in-the-middle attack (Exercise 11.3).Cslib.Crypto.KeyExchange.xorKeyExchange,Cslib.Crypto.KeyExchange.xorEavesdropper: the XOR protocol of Exercise 11.4 and the eavesdropper that recovers its key.
Main results #
Cslib.Crypto.KeyExchange.withSetup_realView_bind,Cslib.Crypto.KeyExchange.withSetup_idealView_bind: a protocol that draws public parameters first is attacked by drawing them, then running the fixed experiment.Cslib.Crypto.PrimeOrderGroupFamily.isPPTOn_dhExecutionProb,Cslib.Crypto.PrimeOrderGroupFamily.dhKeyExchangeProb_correct,Cslib.Crypto.PrimeOrderGroupFamily.dhKeyExchange_correct: honest fair-coin execution is uniform strict PPT, and Alice and Bob output the same key.Cslib.Crypto.PrimeOrderGroupFamily.advantage_bind_dhKeyExchangeProb_le,Cslib.Crypto.PrimeOrderGroupFamily.advantage_eavGame_dhKeyExchangeProb_le,Cslib.Crypto.PrimeOrderGroupFamily.DDH.dhKeyExchangeProb_eavSecure: explicit2 / 2 ^ nand4 / 2 ^ nexponent-sampling bounds and passive eavesdropper security ofdhKeyExchangeProbunderDDH([KL20], Theorem 11.3, p. 394, locator not verified; registration pending source check, #5657).Cslib.Crypto.PrimeOrderGroupFamily.withSetup_realView_dhExecution,Cslib.Crypto.PrimeOrderGroupFamily.withSetup_idealView_dhExecution: at a fixed group the ideal-sampling experiments are the DDH experiments;realGame_dhKeyExchangeandidealGame_dhKeyExchangeare the family versions.Cslib.Crypto.PrimeOrderGroupFamily.dhMitmExecution_keys,Cslib.Crypto.PrimeOrderGroupFamily.map_aliceView_dhMitmExecution,Cslib.Crypto.PrimeOrderGroupFamily.map_bobView_dhMitmExecution: the attack of Exercise 11.3.Cslib.Crypto.KeyExchange.xorKeyExchange_correct,Cslib.Crypto.KeyExchange.not_eavSecureBits_xorKeyExchange: the analysis of Exercise 11.4.
Ideal-sampling steps #
Cslib.Crypto.PrimeOrderGroupFamily.DDH.dhKeyExchange_eavSecure_ideal: DDH implies security of the ideal-sampling protocoldhKeyExchangeagainst eavesdroppers, a step toward [KL20], Theorem 11.3 (locator not verified) consumed byDDH.dhKeyExchangeProb_eavSecure.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Version 0.6, Section 10.1 (pp. 399–400), Section 10.4.1 (pp. 407–408), and Exercise 10.3 (p. 424).
- J. Katz, Y. Lindell, Introduction to Modern Cryptography, 3rd ed., Section 11.3 (pp. 390–396) and Exercises 11.3–11.4 (pp. 399–400).
The result of one honest execution of a two-party key-exchange protocol: the transcript seen
by an eavesdropper and the keys output by Alice and by Bob, which lie in the key set K transcript
named by the transcript.
- transcript : T
All messages sent between the parties.
- aliceKey : K self.transcript
The key output by Alice.
- bobKey : K self.transcript
The key output by Bob.
A two-party key-exchange protocol with transcripts in T and keys in K transcript, described
by the law of its honest execution at each security parameter.
The law of the transcript and both keys when Alice and Bob run the protocol honestly.
A key-exchange protocol is correct when Alice and Bob output the same key on every honest execution ([KL20], Section 11.3, p. 391).
The encoding of an honest-execution outcome: the transcript encoded by encT, Alice's key
encoded by encK transcript, and Bob's key encoded by encK transcript, each framed except the
last (encOutcome_apply).
What an eavesdropper is given: a transcript and a candidate key for it.
- transcript : T
All messages sent between the parties.
- key : K self.transcript
The candidate key: Alice's key in the real experiment, an ideal key in the ideal one.
The ideal view: run the protocol honestly and pair the transcript with a fresh key drawn from
idealKey transcript. This is what the adversary sees in KE^eav with hidden bit 1
([KL20], p. 391).
An eavesdropper: given the security parameter and a view, it outputs a bit.
Eavesdropper.IsPPT states its efficiency on encodings.
Eavesdropper input (1ⁿ, view): the security parameter in unary, then the view encoded by
encView encT encK. For a constant key encoding these are the words of
encPair encUnary (encPair encT encK) on (n, (transcript, key)).
An eavesdropper is PPT when one uniform strict PPT machine reads encEavInput encT encK and
writes the adversary's bit.
The real eavesdropping experiment KE^eav with hidden bit 0: draw the real view, then run
the eavesdropper on it.
The ideal eavesdropping experiment KE^eav with hidden bit 1: draw the ideal view with key
law idealKey n, then run the eavesdropper on it.
Security against eavesdroppers with ideal-key law idealKey: every uniform strict PPT
eavesdropper has negligible advantage between realGame and idealGame.
Security against eavesdroppers for bit-word keys ([KL20], Definition 11.1, p. 392):
the ideal key is a uniform n-bit word, independent of the transcript.
For a protocol that first draws public parameters p from setup, then runs the execution
execution p, the real experiment draws p and then runs the fixed real experiment of
execution p.
For a protocol that first draws public parameters p from setup, then runs the execution
execution p, the ideal experiment draws p and then runs the fixed ideal experiment of
execution p.
The Diffie–Hellman protocol #
A Diffie–Hellman transcript: the group parameters chosen by Alice and the public shares
hA = x • g of Alice and hB = y • g of Bob in that group.
- groupParameters : F.Desc
The group parameters sent by Alice.
The encoding of a Diffie–Hellman transcript: the group parameters and the words
F.encode d hA, F.encode d hB of the shares, each framed except the last
(encDHTranscript_apply).
The tuple of the fields of encDHTranscript.
A Diffie–Hellman key is an element of the group named in the transcript.
A Diffie–Hellman key is encoded as an element of the group named in the transcript.
A computed Diffie–Hellman key is encoded by the word of the computed group element.
The honest Diffie–Hellman execution in the group d ([KL20], Construction 11.2,
pp. 392–393). Alice draws a uniform exponent x and sends d and hA = x • g; Bob draws a
uniform exponent y and sends hB = y • g. Alice outputs x • hB and Bob outputs y • hA.
Both exponents are drawn exactly uniformly on ZMod q at the PMF level, an ideal sampler that
no fair-coin machine with a strict polynomial time bound realizes exactly when q is not a power of
two (#5293).
The Diffie–Hellman key-exchange protocol ([KL20], Construction 11.2): Alice draws
the group parameters d from setup n, then the parties run dhExecution d.
Every honest Diffie–Hellman execution in the group d is (d, x • g, y • g) with both keys
equal to (x * y) • g.
Alice and Bob output the same key, (x * y) • g ([KL20], p. 393).
The ideal key of [KL20], Theorem 11.3 (p. 394): a uniform element of the group named in the transcript.
Run an eavesdropper on Diffie–Hellman views as a DDH distinguisher: the elements (u, v, w)
of the group d are passed on as the transcript (d, u, v) with key w.
At a fixed group, the real eavesdropping experiment on Diffie–Hellman is the real DDH experiment.
At a fixed group and with the uniform group element as ideal key, the ideal eavesdropping experiment on Diffie–Hellman is the random DDH experiment.
The real eavesdropping experiment on Diffie–Hellman is the real DDH experiment.
With the uniform group element as ideal key, the ideal eavesdropping experiment on Diffie–Hellman is the random DDH experiment.
The distinguisher dhEavToDDH is uniform strict PPT when the eavesdropper is.
Ideal-sampling step toward [KL20], Theorem 11.3, p. 394 (locator not verified), not
the cited result: if the Decisional Diffie–Hellman assumption holds for setup, then no uniform
strict PPT eavesdropper distinguishes the transcript and Alice's key of dhKeyExchange setup,
whose parties draw their exponents exactly uniformly on ZMod q at the PMF level, from the
transcript and a uniform element of the same group. Consumed by DDH.dhKeyExchangeProb_eavSecure,
which replaces exact uniform exponent draws with the fair-coin sampler sampleExp.
Fair-coin Diffie–Hellman execution #
The honest fair-coin Diffie–Hellman execution in the group d at security parameter n
([BS23], Section 10.4.1, Figure 10.2, pp. 407–408). Alice and Bob each sample an exponent
with F.sampleExp n d (within statistical distance 1 / 2 ^ n of uniform on ZMod (F.order d));
Alice sends hA = x • g and Bob sends hB = y • g, and Alice outputs x • hB while Bob outputs
y • hA.
The fair-coin Diffie–Hellman key-exchange protocol ([BS23], Section 10.4.1,
Figure 10.2, pp. 407–408): public group parameters d are drawn from setup n, then Alice and Bob
run dhExecutionProb n d using sampleExp.
dhExecutionProb is uniform strict PPT whenever n and d are computable in polynomial
time.
In every honest fair-coin Diffie–Hellman execution, Alice and Bob output the same key
((x : ZMod q) * y) • g.
Replacing dhKeyExchangeProb by the exact-uniform dhKeyExchange before any Boolean game
continuation k changes Game.advantage by at most 2 / 2 ^ n (1 / 2 ^ n for each party's
sampleExp draw).
Against dhKeyExchangeProb, any eavesdropper's advantage between the real key and the uniform
group-element ideal key dhIdealKey is at most its DDH advantage via dhEavToDDH plus the
4 / 2 ^ n fair-coin sampling loss (2 / 2 ^ n in each of the real and ideal games).
Under DDH, Diffie–Hellman key exchange is secure against passive eavesdroppers
([KL20], Section 11.3, Theorem 11.3, p. 394, locator not verified; registration pending
a source check against [KL20] Chapter 11, #5657; compare the session-key
indistinguishability remark of [BS23], Section 10.1, p. 400): if F.DDH setup holds,
then the fair-coin protocol dhKeyExchangeProb setup satisfies KeyExchange.EavSecure against
uniform strict PPT eavesdroppers when the ideal key is the uniform group element dhIdealKey.
Derived from DDH.dhKeyExchange_eavSecure_ideal and advantage_bind_dhKeyExchangeProb_le with
fair-coin sampling loss at most 4 / 2 ^ n.
The man-in-the-middle attack #
The outcome of the man-in-the-middle attack of [KL20], Exercise 11.3 (p. 399): the view of Alice and of Bob, each made of the transcript that party sees and the key it outputs, and the keys the adversary computes for its sessions with each of them.
Alice's view: the transcript
(d, hA, hB')with the substituted sharehB', and her key.Bob's view: the transcript
(d, hA', hB)with the substituted sharehA', and his key.The key the adversary computes for its session with Alice.
The key the adversary computes for its session with Bob.
The man-in-the-middle attack on Diffie–Hellman in the group d ([KL20],
Exercise 11.3, p. 399). Alice and Bob run Construction 11.2 honestly with exponents x and y.
The adversary draws its own exponents x' and y', delivers hB' = y' • g to Alice in place of
hB and hA' = x' • g to Bob in place of hA, and computes y' • hA and x' • hB. Over a setup
law, the attack draws d first.
In the man-in-the-middle attack the adversary knows the key Alice outputs and the key Bob outputs.
Alice cannot detect the attack: her view has exactly the law of the eavesdropper's view of an honest Diffie–Hellman execution.
Bob cannot detect the attack: his view has exactly the law of the eavesdropper's view of an honest Diffie–Hellman execution.
A protocol built from XOR masks #
The encoding of an XOR transcript: its three words, each framed except the last
(encXorTranscript_apply).
The XOR w ⊕ (s ⊕ u) of the three words of an XOR transcript.
The protocol of [KL20], Exercise 11.4 (p. 400). Alice draws uniform n-bit words
k and r and sends s = k ⊕ r; Bob draws a uniform n-bit word t and sends u = s ⊕ t;
Alice sends w = u ⊕ r. Alice outputs k and Bob outputs w ⊕ t.
Every honest execution of the XOR protocol comes from n-bit words k, r and t.
Alice and Bob output the same key ([KL20], Exercise 11.4, p. 400).
The eavesdropper that accepts exactly when the candidate key is the XOR w ⊕ (s ⊕ u) of the
three transcript words.
On the real key the eavesdropper always accepts.
On a uniform n-bit key the eavesdropper accepts with probability at most 1 / 2 ^ n.
From n = 1 on, the eavesdropper's advantage is at least 1 / 2.
The XOR eavesdropper is uniform strict PPT.
The XOR protocol is not secure against eavesdroppers ([KL20], Exercise 11.4,
p. 400): the XOR of the three transcript words is the key, so the eavesdropper
xorEavesdropper has advantage at least 1 / 2 at every parameter n ≥ 1.