Back

## Diffie-Hellman Worksheet

(Suggestion for the first time through: use P=257 and N=3)

Fix a modulus P = _________ and a base N = _________, which are known to everybody (typically, P is prime for this system and N is a "primitive root" meaning the powers of N are all different modulo P, until the (P-1) power of N is 1, by Fermat's little theorem).

Pick your secret exponent E = ________ (E and (P-1) should have no common factors, besides 1.).

Find all of the powers of N modulo P listed below, reducing modulo P after every step:

 N (mod P) = ________ N2 (mod P) = ________ N4 (mod P) = ________ N8 (mod P) = ________ N16 (mod P) = ________ N32 (mod P) = ________ N64 (mod P) = ________ N128 (mod P) = ________

Now, find the powers above that sum to E, and compute J = NE (mod P) by multiplying those powers of N together. [For example, if E = 113, E = 64 + 32 + 16 + 1. Then, J = NE (mod P) = N64 * N32 * N16 * N (mod P).]

J = _________

Now compute KE (mod P) by the same repeated squaring method:

 K (mod P) = ________ K2 (mod P) = ________ K4 (mod P) = ________ K8 (mod P) = ________ K16 (mod P) = ________ K32 (mod P) = ________ K64 (mod P) = ________ K128 (mod P) = ________

KE (mod P) is the secret number you have with the other group!