Home

# The Diffie-Hellman key exchange

Take on the roles of Alice and Bob! Exchange secret keys using the Diffie-Hellman key exchange method!! Use your keys to encrypt messages!!!

The Diffie-Hellman key exchange uses a large prime p and a primitive root g of this prime. These numbers are both public.

To start the key exchange process, Alice chooses a secret number a less than the large prime, and computes ga (mod p). Alice sends this answer, call it A, to Bob. Bob now chooses his own secret number b, and computes gb (mod p). Bob sends this answer, call it B, to Alice.

Finally, Alice computes Ba (mod p), and Bob computes Ab (mod p). They both get the same answer, but no-one else will know this secret answer, because only Alice knows a, and only Bob knows b. This secret answer is their private key, which they can use to encrypt messages.

[You may wonder why someone intercepting Alice and Bob's communication can't solve gx = A (mod p) to calculate Alice's secret number a. This is a hard problem, known as the discrete logarithm problem. That this is difficult is the strength of this method of key exchange.]

First you must be Alice. Choose a large prime from the list below (or one of your own choice) and a corresponding primitive root of that large prime. Then choose a secret number which is smaller than your large prime.

• 22953686867719691230002707821868552601124472329079 primitive root 11
• 30762542250301270692051460539586166927291732754961 primitive root 7
• 29927402397991286489627837734179186385188296382227 primitive root 2
• 95647806479275528135733781266203904794419563064407 primitive root 5
• 48705091355238882778842909230056712140813460157899 primitive root 6
• 53542885039615245271174355315623704334284773568199 primitive root 3
• 622288097498926496141095869268883999563096063592498055290461 primitive root 2
• 610692533270508750441931226384209856405876657993997547171387 primitive root 2
• 4669523849932130508876392554713407521319117239637943224980015676156491 primitive root 3
• 4906275427767802358357703730938087362176142642699093827933107888253709 primitive root 2
• 18532395500947174450709383384936679868383424444311405679463280782405796233163977 primitive root 5
• 282755483533707287054752184321121345766861480697448703443857012153264407439766013042402571 primitive root 2
(mod )