What should be the value of x and y in Diffie Hellman Key Exchange Algorithm?

shivajikobardan

Junior Member
Joined
Nov 1, 2021
Messages
107
I'm not asking it from "will it be secure" point of view, rather I'm asking textbook kind technically correct or not.

This is the algorithm (in the 3rd step of right figure, it should be generate y, typo)
AvgI3gcpc9HMbdMuWa_q85P1pvdAqF7ade3fxDY9F3sgu0q4Po8WgkGZB_mrH1vZHrTHh77_RHOeV0ryi3bVGKMOBHcoiky_J6qdb9IWDlvSu8GjmLSaRjhsWGGFvdRQWinKtMsC4G10LfaUD3Aqvtq8qGaDEdc-QKSOH1G7MI7iKtKn_Mwp14BRgQ

I took p=23,g=5.
And picked x=4,y=5
I got the secret key as 12 and both got 12, so it looks like the algorithm worked. But were there any restrictions and if this was a fluke?

What I'm aware?
x,y should be random. And x,y range from 1 to p.
 
But were there any restrictions and if this was a fluke?
According to Wikipedia (https://en.wikipedia.org/wiki/Diffie–Hellman_key_exchange#Cryptographic_explanation):

The simplest and the original implementation[2] of the protocol uses the multiplicative group of integers modulo p, where p is prime, and g is a primitive root modulo p.​
As far as I can tell, both requirements are needed for stronger encryption, but the key exchange would work with non-prime 'p' and non-primitive root 'g'. If those restrictions are not enforced one would be more likely to end up with 0 or 1 for the "secret" key.
 
Top