# If 1 can be a random number in Diffie-Hellman Algorithm

I've done some calculations and Diffie-Hellman Algorithm worked for all chosen random numbers except $$1$$. In the description of the algorithm, I can't find information that the random number has to be higher than $$1 (r>1)$$.

• Could you explain to me if I made a mistake or where I can find information that $$r$$ cannot be $$1$$?
• Why shouldn't it work for 1? Can you please describe the problem there / give an example? (Preferably using an edit?) – SEJPM Apr 16 '19 at 19:40
• Wikipedia says from $1$ to $p-1$. Could you provide your source? – kelalaka Apr 16 '19 at 19:55
• My best guess is that you're using an existing DH library which has been programmed to reject the $r=1$ case... – poncho Apr 16 '19 at 21:03
• Of course such "errors" would go unnoticed for a sufficiently large maximum for $r$, which would be the case for any known set of secure parameters. The chance of generating 0 or 1 would be insignificant, and even if it was generated it is likely that it is simply rejected and that a new random is generated. Basically it is just slightly annoying when you're performing boundary tests. By the way, you were asked for a source, and I might close the question without one, as we cannot seem to answer otherwise. – Maarten Bodewes Apr 17 '19 at 15:53