Alice and Bob agree to create a secret encryption key for future correspondence according to the Diffie-Hellman Key Exchange Protocol. Over a public communications channel, they agree upon a prime base of $5$ and a modulus of $23$. Alice then sends Bob the value $8$, and Bob sends Alice the value $19$. What is their agreed upon secret encryption key? What could they have done to better protect the secret key they generated? (*Hint: You may wish to refer to the table of powers and indexes $\pmod{23}$ provided below.*)

Recall, Alice has secretly chosen an exponent $a$ and sent Bob $5^a$, while Bob has secretly chosen an exponent $b$ and sent Alice $5^b$. Each can then take the other's sent number and raise it to their own secret exponent to obtain $5^{ab}$, the secret agreed-upon key.

However, Alice and Bob did not choose a modulus near large enough to prevent an eavesdropper like us from solving for $a$ and $b$.

We know that $5^a \equiv 8 \pmod{23}$ and $5^b \equiv 19 \pmod{23}$.

Consulting the table given suggests that $a = 6$ and $b = 15$. (*Note that we need not be given the table to solve the problem -- we could have easily constructed it from scratch.*)

It remains to calculate the value of the secret key...

$$5^{ab} = 5^{6 \cdot 15} = 5^{90} = (5^{22})^4 \cdot 5^2 \equiv 5^2 \equiv 2 \pmod{23}$$