I am trying to work out the shared key between Alice and Bob in DHKE equation. The generator is 7 and the Prime P = 71. Bobs private choice of number is 28 and he also receives g ^ A = 70 from Alice. Alice does not seem to have a private choice of number in this equation, all I know is that g ^ A = 70. So how can I calculate the value of the shared key?

I am just having difficulty working it all out. The modulus arithmetic involved is also confusing me. If someone could try to explain it to me.

I know that it must be: A = 7^x (Mod 71) = 70; and: B = 7^28 (Mod 71);

Then Alice Computes: gB ^ A (Mod 71); and Bob Computes: (gA)^28 (Mod 71);


You are confusing your notation. You are saying that $g^A\equiv 70 \bmod{71}$, but then you are also saying that $A\equiv 7^x\bmod{71}$. That is not true. So let's clarify the notation.

Let $A$ be Alice's private exponent and $B$ be Bob's private exponent.

You know that $B=28$ and you know that $g^A\equiv 70\bmod{71}$. You do not know $A$, however, but you do not need to know $A$.

The shared key between Alice and Bob is ${g^A}^B\equiv {g^B}^A \bmod{p}$. So given what you know, you can compute the shared secret.

To figure out what Alice's private exponent is, you would have to solve the discrete logarithm. For numbers this small, that would be easy, but in general (and for the size of numbers we use in practice) that is infeasible.

  • $\begingroup$ Thank you for your advice. I understand now where I was going wrong and I also know how to compute the answer from studying your suggestion. $\endgroup$ – GreenCoder90 Apr 10 '18 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.