Implement function to generate random n-bit safe primes