-
Notifications
You must be signed in to change notification settings - Fork 430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PCG 128-bit generators are easy to predict #905
Comments
Hello, I agree that "difficult to predict" claims are often unsubstantiated when perhaps they should be. My appologies may be due here — I missed that you have broken PCG64 — is this a recent? I will take a closer look. About the latter point: see rust-random/rngs#3 |
Oh, like, yesterday 😂. No apologies needed. |
To clarify, we make claims about predictability in the Rand book:
PCG XSL 128/64 (LCG) is the only RNG rated with four stars, claiming it is non-trivial to predict. I don't think this is the same as claiming it is difficult to predict, but I agree that this statement should be removed, because I don't think it is a useful criterion of quality. Maybe let's just get rid of the four-star rating? Note that we later claim the following:
|
Admittedly I missed the fine print 🙄. Yet, most users will probably do the same. "Non-trivial" is not a formal concept, so you decide what it means. In my mind it is "computationally nontrivial", which means it would take, say, years to derive the current state from the observed output. |
I guess that's an option. Inventing useful ratings is hard, especially ones based on provable properties.
This is again something hard to prove, outside of cryptographic RNGs. Perhaps we should just avoid the term. Getting this stuff right is hard. (Or maybe just outside my expertise.) Would someone like to volunteer a PR on the book? |
I totally feel you—it's a mess (BTW, if you're interested in comments on the book let me know, it's very well written but still I might have useful suggestions). It's really hard. Personally, I don't believe in the "middle ground" of "difficult-to-predict-but-not-crypto": usually it just means it is so easy to break that nobody tries. I mean, I can claim that Note that, BTW, PCG generators have other known problems, one of which is no right state propagation. Try the following program:
The two generators start from different states, so they should (reasonably quickly) diverge. But after 10 million iterations you can see (even without a test suite) that the outputs are identical—they're just shifted around a bit. |
@vigna I just tried your example, and the results do appear quite different to me (third column is
Perhaps you meant to adjust one bit in the second key (i.e. the stream) instead? In that case, it appears that for every 16th sample, Certainly we'd be happy to have feedback on the book. I couldn't find good references for some of the contents (or had insufficient motivation to do serious research), so some sections may lack precision / justification. |
XOR does not help, because the bit sequences are shifted. Looking at the last values:
Note that both strings are almost identical if you shift them:
|
Yes, it's just a matter of bit patterns:
These two outputs (the first line) are essentially the same. Just rotated a bit. Of course they are statistically strongly dependent, even after 10 million iterations. This is not going to change, no matter how you iterate, because the state change will never propagate to the right. This is an extreme example (same lower 127 bits), but even the same lower 64 bits are sufficient to generate correlated sequences (there's a C example at http://prng.di.unimi.it/pcg.php) that will make PractRand fail. "Same 64 lower bits" means a nonnegligible probability, in the order of 1 in a few billions, by the Birthday Paradox. UPDATE: Note that the example above uses a slightly different output function (there are so many). So it might not work in your case. |
@dhardy How can I write you in private (for the book)? Or do you prefer an issue? |
We usually use public issues; you can do so on the book repository directly. Or is there some reason you'd prefer private communication? If so try 'hello' @ my domain (see commits). |
The book repository is fine. Can you point me at it? |
Due to close correlations of PCG streams (rust-random#907) and lack of right-state propegation (rust-random#905), the `SmallRng` algorithm is switched to xoshiro{128,256}++. The implementation is taken from the `rand_xoshiro` crate and slightly simplified. Fixes rust-random#910.
Due to close correlations of PCG streams (rust-random#907) and lack of right-state propagation (rust-random#905), the `SmallRng` algorithm is switched to xoshiro{128,256}++. The implementation is taken from the `rand_xoshiro` crate and slightly simplified. Fixes rust-random#910.
Due to close correlations of PCG streams (rust-random#907) and lack of right-state propagation (rust-random#905), the `SmallRng` algorithm is switched to xoshiro{128,256}++. The implementation is taken from the `rand_xoshiro` crate and slightly simplified. Fixes rust-random#910.
There has been a cryptanalysis of PCG64, recovering the seed. |
I think we are no longer making any claims that PCG is difficult to predict, therefore I believe this is fixed. |
I just stumbled into the documentation for the package, which scores PCG64 (the 128-bit version) as "difficult to predict". This has always been an unsubstantiated, but also not refuted claim. You can now find here a simple C++ program predicting easily the output of a PCG64 generator from its output:
http://prng.di.unimi.it/pcg.php#claims
(BTW, thanks for implementing
xoshiro256**
. It turned out, however, thatxoshiro256++
bulk generation vectorizes immensely better on AVX2 architectures, so this is what we are suggesting to use now.)The text was updated successfully, but these errors were encountered: