fwiw Dept:
As part of my attempts to resolve the apparent contradiction between the assertions about how primes are filtered in Gapcoin [1] and how that's done in the actual PoWCore source code, I scraped j0nn9's posts to this, the Gapcoin thread, sorted them into ascending order and rendered the result as a standalone page of HTML that I have published as a github gist which can be saved and opened in a browser:
https://gist.github.com/gjhiggins/75073257527aa6304b3913688f2b46c8[1]
Gapcoin follows Riecoin's way and uses enough Miller-Rabin tests with random bases to avoid composite numbers being accepted as Prove of Work.Added:In an effort after greater clarity, I distilled and categorised the posts, rendering them as a page of HTML that uses jquery and semantic-ui to present the posts in a series of accordion (drop-down) sections for ease of consumption:
https://gist.github.com/gjhiggins/dded25cb7a6d46531a3c8bd52074bde4BTW, I found out what [1] was about and annotated my own copy of Gapcoin-PoWCore's PoW.cpp (
https://github.com/gapcoin/Gapcoin-PoWCore/blob/06ac3fea780997232e9d5c78bfaf34d72e1b4e13/src/PoW.cpp#L130) with the docs of the gmplib functions
mpz_probab_prime_p and
mpz_nextprime:
/* start has to be a prime */
/*
Function: int mpz_probab_prime_p (const mpz_t n, int reps)
Determine whether n is prime. Return 2 if n is definitely prime,
return 1 if n is probably prime (without being certain), or
return 0 if n is definitely non-prime.
This function performs some trial divisions, then reps
Miller-Rabin probabilistic primality tests. A higher reps value
will reduce the chances of a non-prime being identified as probably prime.
A composite number will be identified as a prime with a probability of less
than 4^(-reps). Reasonable values of reps are between 15 and 50.
*/
if (!mpz_probab_prime_p(mpz_start, 25)) {
mpz_clear(mpz_start);
return false;
}
mpz_init(mpz_end);
/*
Function: void mpz_nextprime (mpz_t rop, const mpz_t op)
Set rop to the next prime greater than op.
This function uses a probabilistic algorithm to identify primes.
For practical purposes its adequate, the chance of a composite
passing will be extremely small.
*/
mpz_nextprime(mpz_end, mpz_start);
return true;
(In case anyone other than me is interested.)
Cheers
Graham