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$?
  • 2
    $\begingroup$ Why shouldn't it work for 1? Can you please describe the problem there / give an example? (Preferably using an edit?) $\endgroup$ – SEJPM Apr 16 at 19:40
  • 1
    $\begingroup$ Wikipedia says from $1$ to $p-1$. Could you provide your source? $\endgroup$ – kelalaka Apr 16 at 19:55
  • 1
    $\begingroup$ My best guess is that you're using an existing DH library which has been programmed to reject the $r=1$ case... $\endgroup$ – poncho Apr 16 at 21:03
  • $\begingroup$ 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. $\endgroup$ – Maarten Bodewes Apr 17 at 15:53

Your Answer

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

Browse other questions tagged or ask your own question.