LearnViz Math
Expert ⛓ Discrete Math & Number Theory Topic 97 of 103

Diffie–Hellman Key Exchange

Shared secret from public values.

Key idea

Shared secret from public values.

In depth

Two people agree on a prime p and base g, pick secret numbers a and b, and exchange gᵃ and gᵇ mod p. Each computes the same shared key gᵃᵇ. Eavesdroppers face the discrete logarithm problem.

Worked example

p = 23, g = 5, a = 6, b = 15: A = 8, B = 19; shared key 2.

Real-world uses

Common mistake

Forgetting it provides no authentication by itself.

How to learn this

  1. Read the key idea and say it in your own words.
  2. Work through the worked example, then try a similar problem.
  3. Use the interactive lesson’s visual and mini-quiz to check the pattern.

Frequently asked questions

What is Diffie–Hellman Key Exchange?

Shared secret from public values. It is a topic at the expert level in Discrete Math & Number Theory.

Where is Diffie–Hellman Key Exchange used in real life?

Real-world examples: Agreeing a secret key over an insecure connection, such as in messaging apps and VPNs.

What should I learn before Diffie–Hellman Key Exchange?

Make sure you are comfortable with RSA Cryptography, the previous topic in Discrete Math & Number Theory.

What is a common mistake with Diffie–Hellman Key Exchange?

Forgetting it provides no authentication by itself.

How can I practise Diffie–Hellman Key Exchange?

Open the interactive lesson, play with the visual, then answer the three-question mini-quiz. Getting two right marks the topic complete.

What comes after Diffie–Hellman Key Exchange?

Move on to Hash Functions and Checksums next.

Related expert topics in Discrete Math & Number Theory