-
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
Could rand
changes slow down and simplify the API before making new versions?
#704
Comments
Just to be clear, this is feedback only from my perspective as a crate user, I'm not claiming that this is the be-all, end-all perspective, just writing it down for consideration. I'd be happy to help make progress towards these changes if that's the direction the |
There's a tension between cryptographic uses of |
A lot of thought went into the design of We could possibly use two levels of API: crypto-oriented byte-only, then general-purpose RNG — but this would be more complexity, not less.
As to a crate exposing only Why bring up the algorithms here? There are other threads on that, and it has nothing to do with the APIs. We deliberately do not keep the versions in sync between crates to minimise the effort needed to update. The |
Okay, if that's the case, it's the case; a pure byte-oriented API isn't essential (although an
That's great, is the plan for the
I didn't suggest that there should be a crate exposing only
This is a suggestion about the
I brought up algorithms because they do matter, and because there exist secure algorithms that provide exceptionally high speed (< 1 cycle per byte), obviating the need for the
With respect, I and others see a lot of breakage, so, as a user, this decision doesn't seem to actually translate into minimized effort. |
We only want to implement the OS stuff once so we will re-use the implementation. Once it is ready we will of course advertise the new function. |
Opinion noted. Now go do a search and see why some people are using High speed on aggregate usage isn't all we look for in algorithms; low memory usage and highly predictable performance also have their perks. Most crypto algorithms are optimised to produce large blocks of data and not for other uses.
What kind of breakage? |
Note that you can already use I am not sure why I think we should expose @dhardy |
@newpavlov I'd rather get this |
Yes, I will try to create a PR on this weekend. |
E.g. #705 |
Fair point, we did deprecate the old I think the answer to your question in the title can only be no. (I'm not actually sure how to simplify without making new versions.) In any case, we still try to support Rand back to 0.4 (even with a new 0.3 release recently), so there shouldn't be too much pressure to upgrade, however all versions since 0.5 support the same core There are already two threads on potential changes to the The only remaining point I see here is regarding wanting only Is there anything else to take away from this issue before closing it? BTW: tracker for 0.7 features: #715 |
Here is an example of breakage that someone else ran into: BurntSushi/quickcheck#228 (I don't know how they got into that state, and I'm not 100% sure on my diagnosis, but it certainly seems related to the semver trick.) |
@oleganza |
Yes, that problem was caused by my changes, it's not related to this issue. The new trait bound uses |
For those who want to use it, the getrandom crate is now available. To those who want RNGs but none of the algorithms, we already have much of this available outside the You may also be interested to know that the |
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:OsRng
, which calls a secure platform API to get random bytes, or fails closed.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 thenext_u32
andnext_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.
The text was updated successfully, but these errors were encountered: