-
-
Notifications
You must be signed in to change notification settings - Fork 480
Description
Hi there,
apologies if this has already been discussed in other places, but there's a lot of issues and discussion and it's hard to keep track as an outsider.
Just from the point of view of (this) user of the rand crate, the changes are kind of hard to keep track of, and it feels like there's a lot of churn without really making fundamental changes.
Here are some comments, from my perspective, for consideration:
Ideally, my preference would be for the rand crate to expose only two RNGs:
- an
OsRng, which calls a secure platform API to get random bytes, or fails closed. - a
ThreadRng, which uses a secure, well-studied construction internally, such as AESNI when available, or ChaCha20 otherwise.
Any cases where people really care about performance (e.g., someone needs to generate a lot of floats) are probably cases where AESNI is available, and since AESNI costs <1 cpb, there should not be a performance concern.
The RngCore trait could also be simplified, removing the next_u32 and next_u64 methods. In this way, the core RNG functionality can be byte-oriented, and all other functionality can be layered on top by means of extension traits.
Also, the semver trick is really difficult to get right, and subtle interactions cause a lot of unexpected breakage. My preference would be to get the API right, and then make a clean break.