A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Diffie-Hellman Key Exchange

Graduate Depth 82 in the knowledge graph I know this Set as goal
24topics build on this
399prerequisites beneath it
See this on the map →
Discrete LogarithmsModular Arithmetic and Congruences+1 moreComputational Hardness AssumptionsElliptic Curve Cryptography Basics+1 more
diffie-hellman key-exchange discrete-logarithm-problem man-in-the-middle

Core Idea

Diffie-Hellman (1976) allows two parties to establish a shared secret key over a public channel without any prior shared secret. Both parties agree on a public prime p and generator g. Alice picks secret a, sends ga mod p; Bob picks secret b, sends gb mod p. Both compute the shared key gab mod p. Security rests on the Computational Diffie-Hellman (CDH) assumption: given ga and gb, computing gab is hard without knowing a or b. DH is vulnerable to man-in-the-middle attacks without authentication. The protocol also works over elliptic curve groups (ECDH), offering equivalent security with smaller parameters.

Explainer

In 1976, Whitfield Diffie and Martin Hellman published a protocol that solved one of the oldest problems in cryptography: how can two people who have never met establish a shared secret over a channel that anyone can listen to? Before their work, all encryption required a pre-existing shared key — to communicate securely, you first needed a secure channel to exchange keys, which was precisely the problem you were trying to solve. Diffie-Hellman key exchange breaks this circularity using the one-way nature of modular exponentiation.

The protocol is remarkably simple. Alice and Bob publicly agree on a large prime p and a generator g of a multiplicative group modulo p. Alice picks a random secret integer a and sends A = ga mod p to Bob. Bob picks a random secret b and sends B = gb mod p to Alice. Alice computes K = Ba = gba mod p; Bob computes K = Ab = gab mod p. Both arrive at the same shared secret K = gab mod p. An eavesdropper sees g, p, ga, and gb, but computing gab from this information appears to require solving the Computational Diffie-Hellman (CDH) problem, which is believed hard in well-chosen groups. The eavesdropper would need to either compute a discrete logarithm (find a from ga) or find some other way to compute gab — and no efficient method is known.

The main vulnerability of basic DH is man-in-the-middle attack. An active attacker Mallory can intercept Alice's message, replace it with her own public value, and do the same to Bob. She ends up sharing one key with Alice and a different key with Bob, relaying (and reading) all messages between them. Neither Alice nor Bob detects the interception because basic DH provides no authentication — they have no way to verify whose public value they received. The solution is to authenticate the DH exchange, typically by having each party sign their DH public value with a long-term digital signature key (as in the TLS handshake) or by using certificates from a trusted authority.

Modern deployments predominantly use Elliptic Curve Diffie-Hellman (ECDH), which performs the same protocol in an elliptic curve group rather than a multiplicative group modulo a prime. Elliptic curve groups resist the index calculus attacks that apply to modular arithmetic, so a 256-bit elliptic curve provides approximately the same security as a 3072-bit prime — dramatically smaller keys and faster computation. TLS 1.3, the protocol securing most web traffic, mandates ECDH (or its post-quantum successors) and has removed classical DH entirely. The conceptual contribution of Diffie and Hellman — that secure key agreement is possible over public channels — remains the intellectual foundation of internet security, even as the specific groups and parameters evolve.

Practice Questions 5 questions

Prerequisite Chain

Understanding ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersIntroduction to ExponentsOrder of OperationsInteger Order of OperationsVariable ExpressionsThe Distributive PropertyVariables and Expressions ReviewIntroduction to PolynomialsAdding and Subtracting PolynomialsMultiplying PolynomialsFactorialPermutationsCombinationsCounting Principles: Addition and Multiplication RulesIntroduction to Graph TheoryPropositional Logic FoundationsLogical EquivalencesSet Operations: Union, Intersection, and ComplementProof by CasesProving by Cases and ExhaustionVacuous Truth and Trivial CasesProof by Cases (Proof by Exhaustion)Mathematical InductionDivisibility and Greatest Common DivisorThe Fundamental Theorem of ArithmeticDivisibility Theory (Formal Treatment)Fundamental Theorem of Arithmetic (Rigorous Proof)Arithmetic Functions and MultiplicativityEuler's Totient FunctionPrimitive Roots and Cyclic Groups Mod pDiscrete LogarithmsDiffie-Hellman Key Exchange

Longest path: 83 steps · 399 total prerequisite topics

Prerequisites (3)

Leads To (3)