# Is Diffie-Hellman less secure when A and B select the same random number? [duplicate]

I understand that it is feasibly impossible for A and B to select the same random number, given the large input space, but what if it does happen? Does it effect the security of the key exchange? Can an attacker determine that the same keys were chosen?

• Welcome to Cryptography.SE. What is the origin of this question? Do you know the probability of it? negligible! So you asking given $g^x$ find $g^{x^2}$. What have you tried? And note we have dupes! Commented Nov 9, 2021 at 22:58
• The question came up in a discussion around the Diffie-Hellman key exchange, and Google did not provide an answer. From this question, I understand that the probability is somewhere in the order of 1/((2^256)^2). However, my understanding of the mechanism of Diffie-Hellman is not much deeper than the paint analogy, in which it would be trivial to detect that A and B are using the same secret key. Commented Nov 9, 2021 at 23:10
• It is called Square Diffie-Hellman.Yes attacker can observe the event if they are lucky. Here another Show How to Efficiently Solve the Computational Diffie-Hellman Assumption given an Algorithm that Solves the Square-DH Problem Commented Nov 9, 2021 at 23:11
• Ah, thank you! I knew that I was just missing enough knowledge to phrase my question properly. Commented Nov 9, 2021 at 23:13