entropyxyz/crypto-primes

Parallel random number generation

fjarri opened this issue · 1 comments

fjarri commented

Generation of random primes can be sped up by parallelizing. On the implementation side, there are two possibilities:

  • Generate several random seeds and run searches based on them in parallel. This will mean that we will have to build the small residues table for each of them, but it is not a big overhead for "production-size" primes (>=1024 bit).
  • Start with the same random seed and a single residue table, and start parallel searches from different points within the range covered by the generated table.

A more complicated part is the API. How do we expose that in the most async-runtime-agnostic way? The parallel tasks will need to take some kind of a signal object as an argument, so that they could be terminated when one task finds a prime. The stop points could even be checked on every internal Miller-Rabin iteration (that is, in-between every modular exponentiation there).