Re: Should we upgrade to a new PRNG in core?
[email protected] (Scott Baker)
| Newsgroups | perl.perl5.porters |
|---|---|
| Message-ID | <[email protected]> |
As the OP on this thread I want to be clear about *my *reasoning for
suggesting we upgrade the PRNG in core:
1. Use a PRNG with better statistical properties
1. Choose a PRNG that passes BigCrush and Smokerand at reasonable
levels (drand48 does not)
2. Get more random bits in our rand() output
1. Doubles can hold 53bits of mantissa, and we're only using 48 in
because of drand48
Smokerand <https://github.com/alvoskov/SmokeRand> test results on drand48:
Passed: 12
Suspicious: 0
Failed: 13
Quality (0-4): 0.00 (very bad)
Same test but run against pcg64_64
Passed: 25
Suspicious: 0
Failed: 0
Quality (0-4): 4.00 (good)
-- Scottchiefbaker
P.S. Here is the command I used for smokerand: bin/smokerand brief
bin/generators/pcg64_64.so --threads
On 1/24/2026 12:20 PM, Russ Allbery wrote:
>> Indeed. But within those confines there are still better algorithms and
>> worse ones. A well-designed PRNG with useful characteristics is a good
>> thing to have for use cases such as sampling and numerical algorithms
>> that do not require actual entropy and may in fact actively disprefer
>> it. So “do we want a better PRNG?” is a worthwhile question even if the
>> answer to “should one use rand() for cryptography?” is “absolutely not”
>> (as you are right to point out) “– that’s not what it’s for”.
> Yes, completely agreed. To be clear, I have no objections to the proposal
> at the start of the thread. I only wanted to clarify that, somewhat by
> definition, replacing the internal PRNG for security reasons isn't really
> something that makes sense.