Math::...mPrimes(3pm)
π NAME π
Math::Prime::Util::RandomPrimes β bestie, this module is literally the "generate me a random prime" department of Math::Prime::Util. That's the whole job description. No cap. π
Oh also? You're reading this in the User Contributed Perl Documentation, on the page Math::...mPrimes(3pm). Just so you know where you are. π«Ά
β¨ VERSION β¨
Version 0.74 β that's the vibe check, and it passed. πΈ
π¦ SYNOPSIS π¦
Okay soβ¦ there is genuinely nothing here. The SYNOPSIS is empty. Not me pointing at an empty section, but ALSO not me making anything up for you. If it's blank, it's blank, and we respect that. π
π DESCRIPTION π
Routines to generate random primes, including constructing proven primes. π
That's it, that's the description. It's giving "short but powerful," and honestly? Iconic. The whole point is: you want a random prime, you come here, you get a random prime. And if you want one that's proven prime β like, certified, card-carrying β that lives here too. π₯
π RANDOM PRIME FUNCTIONS π
The main characters. Every single one of them. π
π random_prime
Generate a random prime between low and high. If given one argument, low will be 2.
So basically: hand it a range, or hand it just the top and it quietly assumes you meant starting at 2. Lowkey thoughtful of it.
π random_ndigit_prime
Generate a random prime with n digits. n must be at least 1.
Counting in digits today, bestie. And n cannot be smaller than 1 β that's the rule, fr fr.
π random_nbit_prime
Generate a random prime with n bits. n must be at least 2.
Same energy, but now we're counting in bits. n must be at least 2. β
π random_maurer_prime
Construct a random provable prime of n bits using Maurer's FastPrime algorithm. n must be at least 2.
Provable, not just "trust me bro." The algorithm is Maurer's FastPrime, and n must be at least 2. π
π random_maurer_prime_with_cert
Construct a random provable prime of n bits using Maurer's FastPrime algorithm. n must be at least 2. Returns a list of two items: the prime and the certificate.
Same as above, except this one comes with receipts β the certificate. You get a list of two items back: the prime, and the certificate. π§Ύβ¨
π random_shawe_taylor_prime
Construct a random provable prime of n bits using Shawe-Taylor's algorithm. n must be at least 2. The implementation is from FIPS 186-4 and uses SHA-256 with 512 bits of randomness.
Okay so the tea here: this implementation is from FIPS 186-4, and it uses SHA-256 with 512 bits of randomness. n must be at least 2. Standards-approved behavior, we love to see it. π
π random_shawe_taylor_prime_with_cert
Construct a random provable prime of n bits using Shawe-Taylor's algorithm. n must be at least 2. Returns a list of two items: the prime and the certificate.
Shawe-Taylor again, cert edition. n must be at least 2, and you get a list of two items: the prime and the certificate. π
π random_safe_prime
Construct a random safe prime of n bits. n must be at least 3.
Safe primes only. n must be at least 3 here β yes, that's different from the others, no, I'm not rounding it down for you. π
π random_strong_prime
Construct a random strong prime of n bits. n must be at least 128.
Heavyweight division. n must be at least 128. That's not a typo and I'm not softening it β one hundred and twenty-eight. Strong primes have standards. πͺ
π random_proven_prime
Generate or construct a random provable prime of n bits. n must be at least 2.
Note the "generate or construct" β it may do either. n must be at least 2. π«Ά
π random_proven_prime_with_cert
Generate or construct a random provable prime of n bits. n must be at least 2. Returns a list of two items: the prime and the certificate.
Same deal, but with the certificate attached. n must be at least 2, and you get back a list of two items: the prime and the certificate. β
πΈ SEE ALSO πΈ
Math::Prime::Utilβ the whole reason this page exists. Go read it, bestie. π
π§ AUTHORS π§
Dana Jacobsen <dana@acm.org>
One person. Carrying this entire module. Respect. π
π COPYRIGHT π
Copyright 2012-2026 by Dana Jacobsen <dana@acm.org>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Which means: yes, you can share it, remix it, redistribute it, modify it β under the same terms as Perl itself. Free as in go off. ποΈ
Okay that's the whole page, you're fully caught up. This was documented for perl v5.42.3, dated 2026-08-20, and that's a wrap on Math::...mPrimes(3pm) β go generate something beautiful and prove it. πβ¨ππ¦
π¦ where this page comes from
- ubuntu stonking: libmath-prime-util-perl 0.74-1build1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms