mpz_probab_prime_p reproducibility

Pierre Chatelier pierre at
Wed Nov 16 16:30:34 UTC 2016

I think that indeed, the *results* are the same (the contrary would be a 
real problem), but not the execution.
The set of miller rabin tests seems not to be the same for two 
consecutive calls, since there is the
mpz_urandomm (x, rstate, nm3) part (and that no deterministic seed seems 
to be used for the randstate)

For pratical purposes it is not a concern, I was just wondering.

> Pierre Chatelier <pierre at> writes:
>    I have checked the source code, and so the answer (in GMP 6.1.1) about
>    reproducibility is no. The miller rabbin tests are done under a
>    gmp_randstate_t, and there is no seed deterministicallly hashed from the
>    number n to test.
> If your use of "reproducibility" is what I think it is, then you have
> misread the source code: the fact is that two consecutive calls with the
> exact same parameters will yield the same results.

More information about the gmp-discuss mailing list