I was looking into GMP documentation. I couldn't find any function for generating random prime of given length. One simple way to do it is:

while true
{
     mpz_urandomb(sampled_value, random_state, length);
     if (!mpz_probab_prime_p(sampled_value, 50))
          break;
}

I was wondering if there is more efficient GMP library function to sample random prime of given length. I would like to sample many random primes. Is there a function that does this more efficiently than sampling each of them in a loop.

0 Answers