Diffie-Hellman key exchange

Diffie-Hellman key exchange uses powers to find a shared secret.

One has to choose a generator base b for the power (usually 2, 3, or 5) and a safe prime number N to be the modulus, the (mod N) part. Typically this is done using a program like openssl dhgen -text 16 which for instance tells me to use N=35963 and b=2 for 16 bits of security (can be broken in much less than a second; real world uses 2048 bits).

You try

(Let a computer or government agency carefully) publicly choose parameters:
b=, N=

Secretly and randomly choose a value for A=
Possible values of A are

A=, so you'll want to find .

Secretly compute:

Now tell you “friend” your final number
bA = .

Your friend publicly tells your their final number is
c=.

Secretly compute:

So that means your shared secret number is
cA = .