Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Randomly generate a safe prime of given length

A prime p is said to be safe prime if (p-1)/2 is also a prime. Safe primes are heavily used in cryptography. In order to generate a random prime of 512 bits, I use

random_prime(2^512-1, false, 2^511)

How to randomly generate a safe prime of given length?