4

When implementing cryptographic/coding theory algorithms one need to use data like big prime numbers, numbers in $Z_n$ and their inverses, irreducible polynomials in $Z_n[x]$ and so on...

While sometimes it is easy to write a simple program to get simple examples of these it's handy to have a list with some non-trivial examples. Do you know where can I find such data?

Mike Edward Moras
  • 18,161
  • 12
  • 87
  • 240
Vicfred
  • 441
  • 2
  • 6
  • 13

3 Answers3

4

Generating prime integers and computing things modulo integers is easy with a programming language which features support for big integers. I usually use Java: it includes java.math.BigInteger, with which one can:

  • generate prime integers of any length;
  • do all basic operations, including modular reduction (mod() method);
  • compute modular inverses (modInverse());
  • compute modular exponentiations (modPow()).

For irreducible polynomials, things are more complex: Java does not offer a generic method for testing irreducibility of polynomials (or, for that matter, anything related to polynomials). I do have my own library but it is not generally available (I implemented it for a customer). However, my friend Google points out that this library appears to be fairly complete in that area.

Thomas Pornin
  • 88,324
  • 16
  • 246
  • 315
2

As far as very large prime numbers, have a look at the following link.

http://primes.utm.edu/largest.html

It gives you a summary of the largest known primes. Good luck with calculating their multiplicative inverses, though. That will not be so easy.

2

If you use a high-level mathematical language (Mathematica, Maple, etc.), generating this data is very easy. I use Mathematica personally, but some are free and apparently very good.

In a pinch, you can use Wolfram Alpha to do a lot:

Generate random prime:

RandomPrime[{2^1023,2^1024}]

Random integer:

RandomInteger[{2^1023,2^1024}]

Inverse mod p: (Returns random prime p, random integer a, a^-1 mod p)

{#,#2,PowerMod[#2,-1,#]}&@@Flatten[{#,RandomInteger[{1,#}]}&/@{RandomPrime[{2^1023,2^1024}]}]

It gets tricky supplying large numbers because queries are limited to 200 characters. Also you can't store variables and use them in subsequent queries. That is why using the actual applications is better. (For example, the last query above would simply be PowerMod[a,-1,p] if you could store a and p after you generate them.)

PulpSpy
  • 8,767
  • 2
  • 31
  • 46