Repository navigation
Closed
Labels
X-trackerType: tracker
Milestone
Description
Add getentropy crate:
- design API, including error type
- port
OsRngcode - port RDRAND code
- make
rand_osa wrapper around this - remove dependence on
JitterRngby default
Target: resolve #648, #699, #681
Follow-up changes:
- replace
EntropyRngandOsRngimpls withgetrandomUse getrandom, simplify OsRng, deprecate EntropyRng #765 - revise
rand_core::Errorand rand_core::Error new version #771, Revise rand_core::Error (alt #771) #800. - support
From<getrandom::Error>(with feature gate) - move
from_entropy()function toSeedableRnggetrandom, security and fallback entropy #760 - reconsider
from_rngand value-stability #572 if we do changerand_core
Clean up dependencies:
- remove deprecation dependencies on
rand_chacha,rand_isaacandrand_xorshift(Remove deprecations #757, Remove dependence on Xorshift, ChaCha and Isaac crates #759)
Distributions:
- move some distributions to an external crate (Future of distributions in rand #290, New rand_distr crate #761)
- revise constructors to return
Resultwhen moving to another crate Error handling in distribution constructors #581, rand_distr: UseResultinstead of panics #770 - make distributions generic of
Floattypes Implement distributions for f32 #100, Make distributions generic / impl for f32 #785, Generic distributions: use custom trait #793 - tweak
Poisson: support FP output and check bound before int conversion (Poisson: Fix undefined behavior and support f64 output #795) - import new
Binomialcode torand_distr(rand_distr: Update binomial distribution implementation #794) - improved testing Testing of distributions #357 (may slip)
Sequences (may slip to later release):
- add weighted choice using alias method WeightedChoice could use the Walker or Vose Alias method for O(1) sampling (instead of O(log n)) #601
- add weighted sampling without replacement Implement weighted sampling without replacement #596
- revise
Distribution::sample_iter(Distribution::sample_iter could use owned values instead of references to be more general #602, Distribution::sample_iter changes #758)
Extras which may slip to later versions:
- make a fast implementation of ChaCha Would this repo be open to a SIMD implementation of ChaCha20? #667 use c2-chacha for stable, runtime-dispatched SIMD #789
- potentially switch
ThreadRngalgorithm Future ofthread_rng#463, Key erasure AES variant #299, Use ChaCha20 in StdRng and feature-gate SmallRng #792
Reacted by Felipe S. S. Schneider
Reacted by Jeff Burdges, Jakub Konka, Mark McCaskey and Michael Mestnik
Metadata
Metadata
Assignees
Labels
X-trackerType: tracker
Activity
vks commentedon Jan 28, 2019
If
ChaChabecomes fast enough, we could consider deprecatingSmallRngand instead suggest the appropriaterand_*crates.dhardy commentedon Jan 28, 2019
Off-topic, and
ChaChais not verySmall. We could consider just deprecating it though.vks commentedon Jan 28, 2019
It is 8.5 times larger than
SmallRng.newpavlov commentedon Mar 7, 2019
Since there are no separate issues yet I will voice my opinion here:
Considering that platform support and ability to overwrite system RNG will be moved to
getrandom, and that we no longer need Jitter fallback I thinkEntropyRngis completely redundant and can be safely removed.Since
getentropywill be foundational either way and implements dummy fallback for unsupported platforms, I thinkrand_corecan depend on it without any problems, soFromEntropybecomes redundant as well and can be removed. It may be a mild annoyance for PRNG crates to transitively depend on crates likelibcorwinapi, but I guess not much harm in that.It's a bit of shame to remove
rand_core::Errorafter amount of effort which was put into it, but I guess there is not much reason to keep a second error type, especially considering thatOsRngwill be a thin wrapper aroundgetrandom.dhardy commentedon Mar 7, 2019
On that topic, having a backup source in Rand may no longer be necessary but is still a nice thing to have. I would prefer using RDRAND over JitterRng now. So I wouldn't say
EntropyRngis completely redundant, but it's also not especially useful.On the other hand, we can't exactly make
SeedableRng::from_entropyuse a back-up source (unless perhaps we implement the RDRAND interface inrand_core), soEntropyRngis useless if we go this route.There is also the question of where
no_stdcompatibility fits into the picture: see rust-random/getrandom#4.We could feature-gate the
getentropydependency (likestd, default disabled inrand_corebut enabled inrand). This avoids the extra dependency for only minor extra complexity.Yes, a lot of effort was put into
rand_core::Error, but it never quite met all requirements. One of the ideas was handling retry-on-interrupt infill_bytesbut not intry_fill_byteswhichOsRngdoes, butgetrandom's current API does not allow this to be implemented properly, and it's probably not very useful anyway.ReseedingRngdoes something similar. So if we simplifyrand_core::Error, thenRngCore::fill_bytesis redundant.Currently
JitterRngalso uses this error type, but I guess this isn't very important.To some up: there are a few steps here that would allow us to simplify Rand (the API at least). Should we take them?
newpavlov commentedon Mar 11, 2019
I believe that without clear examples of non-pathological OS RNG failures we should not be considering including fallback by default at all. In other words today's OS RNGs are already "just work" for all common platforms. And even if such examples would have been present, fallback should be considered only on per-target basis. Also I would repeat again, but I don't think it's a good idea to give a preferential treatment to x86-64 targets by hardcoding RDRAND into the most fundamental layer.
Yes, we already have
stdfeature inrand_core, so it will be reasonable to addgetrandomas an optional dependency and enable it forstd(this way it will be also possible to enablefrom_entropyeven for non-std targets like SGX).We could add
Error::is_retryablemethod which will match on error code and vary between platforms. By default it will match on a third error constant, so custom sources will be able to use this code for signalizing thatgetrandomcall can be retried. But I think we better to continue this discussion in the relevant issue.I think yes, we should do it.
BTW maybe later we should create an announcement on reddit and users forum with planned
rand v0.7changes to gather a wider feedback?dhardy commentedon May 15, 2019
Progress report: we've been making good progress with the distribution work, and were also able to get a faster ChaChaRng (#789). Once #792 and #793 land (soon) a large part of the to-do list will be complete.
The remaining blocking issue is #771 on which @newpavlov and myself have yet to reach an agreement (since he hasn't replied in four weeks, at this point I assume he has lost interest).
dhardy commentedon Jun 5, 2019
We are now close to being ready for a 0.7 pre-release. We should still visit #572 first IMO. Anything else I've missed? (The tracker is out of date; seems my last edit was lost.)
After that some work on documentation is needed (especially in the book); this can happen after the pre-release.
vks commentedon Jun 5, 2019
I don't think there is anything else. Is #572 just about documentation?
dhardy commentedon Jun 5, 2019
It is, though in my mind it is also an API change (not a breaking one but still a significant one), so I'd prefer that done first.
dhardy commentedon Jun 5, 2019
Found another blocker: we need to make a
rand_distrrelease. Is this ready enough? I was intending to release the straight export from Rand as 0.1 and then make 0.2 with our changes, but we don't have to. @vks would you look into this?I'm currently checking other crates (including
rand_chacha 0.2andrand_core 0.5).vks commentedon Jun 5, 2019
@dhardy Done in #816.
dhardy commentedon Jun 12, 2019
The pre-release is out. Reddit thread: https://www.reddit.com/r/rust/comments/bzp5ib/rand_070_prerelease/
huangjj27 commentedon Jun 15, 2019
thread_rngseems not supportingwasm32-unknown-wasion rust stable, with wasmer runtime(on master branch). What should I use when I targeting that?dhardy commentedon Jun 15, 2019
Please take a look at rust-random/getrandom#34, and if it doesn't help open an issue/PR on the getrandom repo. It may be that we should support both
wasm32-unknown-wasiandwasm32-wasi?huangjj27 commentedon Jun 15, 2019
worked with
wasm32-wasibut notwasm32-unknown-wasivks commentedon Jun 25, 2019
I think only #828 is missing for the release? It is probably a good idea to have another pre-release, so we can check whether docs.rs works now.
dhardy commentedon Jun 25, 2019
There's still some doc work needed in the book too.
dhardy commentedon Jun 28, 2019
0.7 has been published.
@vks would you make the reddit announcement? I don't have much time.
newpavlov commentedon Jun 28, 2019
@dhardy
Maybe also make
getrandom v0.1.4release?dhardy commentedon Jun 28, 2019
@newpavlov I just added you to the maintainers team — you should be able to make the release yourself.
vks commentedon Jun 28, 2019
@dhardy https://www.reddit.com/r/rust/comments/c6j6ge/rand_07_release/