Cryptography, Python, Math, Mathematics, Diffie Hellman.
pseudoprime. Otherwise, n is composite. If we want to use a pseudoprime, n, in the Diffie-Hellman Key Exchange, then we need to check if (n-1)/2 is also pseudoprime. We can check this by simply using a slight variation of the Miller-Rabin Primality Test which is shown below. Let x = (n-1)/2.