Safe Prime Database and API

Since our release of the public DH parameter service we have accumulated millions of >= 2048 bit prime numbers, but our original API only allowed access to the most-recent 128 of them. Not only have we opened up the entire database via API, but we have also added JSON output options in addition to dhparam such that education and research can easily integrate safe primes for use in Diffie-Hellman examples using real-world numbers rather than small examples. We will continue to support both API versions.

All of the primes we generate are almost certainly prime. Every randomly sampled prime we have pulled were successfully certified/verified with the ECPP algorithm using Primo. We use an overkill number of Miller-Rabin primality tests on both the safe prime and its Sophie Germain counterpart. Please see the dhtool page for more information about how we generate the primes themselves.

Author rant and visuals

Our author has written a Rants and Musings page to accompany this API that includes dynamically sampled Safe Primes, Sophie Germain primes, as well as example Diffie-Hellman outputs for each.

API for dhparam and JSON

To compliment the original API, we provide a random-selection dhparam service (as well as JSON output) for each of the supported bit sizes. For an in-browser example, get a randomly selected JSON output of: 2048 bit Safe Prime, or 4096 bit Safe Prime, or 8192 bit Safe Prime. Alternatively, for use with OpenSSL et al in dhparam format: 2048 bit Safe Prime, or 4096 bit Safe Prime, or 8192 bit Safe Prime. Continue reading for further API examples and functionality.

# to acquire a randomly selected 2048 bit safe prime as JSON:
$ curl https://2ton.com.au/getprimes/random/2048
# similarly for other bit sizes
$ curl https://2ton.com.au/getprimes/random/3072
$ curl https://2ton.com.au/getprimes/random/4096
$ curl https://2ton.com.au/getprimes/random/8192
#
# for JSONP, add ?callback= to your JSON queries:
$ curl https://2ton.com.au/getprimes/random/2048?callback=safePrimes
#
# to acquire a randomly selected 2048 bit safe prime in dhparam format:
$ curl https://2ton.com.au/getprimes/random/dhparam/2048
# similarly for other bit sizes
$ curl https://2ton.com.au/getprimes/random/dhparam/3072
$ curl https://2ton.com.au/getprimes/random/dhparam/4096
$ curl https://2ton.com.au/getprimes/random/dhparam/8192
#
# We started our prime "mining" on 2015-06-28.
# To get the count for 2048 bit on any given day:
$ curl https://2ton.com.au/getprimes/20180312/2048/count
# To select by index (0-based) on a day in JSON:
$ curl https://2ton.com.au/getprimes/20180312/2048/3
# To select by index (0-based) on a day in dhparam format:
$ curl https://2ton.com.au/getprimes/20180312/dhparam/2048/3