README.germtest
上传用户:zbbssh
上传日期:2007-01-08
资源大小:196k
文件大小:2k
源码类别:

CA认证

开发平台:

C/C++

  1. Test driver for Sophie Germain prime generation.
  2. Generating Sophie Germain primes is the most computationally expensive
  3. thing the math library does at present.  Sophie Germain primes,
  4. (also known as "strong primes," although that term is used to mean
  5. a variety of thints) are odd primes p such that q = (p-1)/2 is also
  6. prime.  It can take a *long* time to fine large (2000-bit and
  7. up) primes.
  8. The command line is a seed string which is used, along with a
  9. compiled-in list of prime sizes, to generate the initial search point
  10. for the prime.  The first (probable) prime after that point is
  11. printed.
  12. germtest Hello, world
  13. germtest `cat /etc/motd`
  14. With the "Hello, world" seed, you will see the uncertainty in the
  15. generation time, as a 1024-bit prime is generated much faster than a
  16. 768-bit prime.
  17. The random-number generator used internally is George Marsaglia's
  18. multiply-with-carry "mother of all random number generators", which
  19. has an interesting relationship to Sophie Germain primes.
  20. The generator is based on the recurrence:
  21. (carry, x[i]) = carry + a1 * x[i-1] + a2 * x[i-2] + ... + ak * x[i-k].
  22. Where x[i] is the result modulo some base b (in germtest.c, b = 65536),
  23. and carry is the overflow, the sum divided by 65536.  
  24. The properties of the generator are controlled by the parameter m,
  25. where m = ak * b^k + ... + a2 * b^2 + a1 * b - 1.  (The "-1" term
  26. is the coefficient of x[i].)  For example, the generator used has
  27. (a1, ..., a8) = (1941, 1860, 1812, 1776, 1492, 1215, 1066, 12013)
  28. This corresponds to
  29. m = 0x2EED042A04BF05D406F0071407440794FFFF
  30. The output of the generator is, in reverse order, the base-b digits
  31. of r/m, for some 0 < r < m.  (Which r depends on the seed.)
  32. If m is a Sophie Germain prime, and b a power of 2, then the period
  33. of the generator will be the prime (m-1)/2.  I.e. the period
  34. of the generator is 1577399102372415483554202684831355506491391,
  35. 1.577 * 10^42, or over 2^140.
  36. With a bit of hacking, this library could be used to search for such
  37. primes quickly, using a combination of the primeGenStrong code
  38. (which searches an arithmetic sequence for primes) and germainPrimeGen,
  39. which finds Sophie Germain primes.  Maybe in the next release...