-
Notifications
You must be signed in to change notification settings - Fork 551
WIP: Bump to rand[_core] 0.9 #729
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
Conversation
@pinkforest it needs to be |
Since Example for ed25519/src/signing.rs pub fn generate<R: RngCore + CryptoRng + ?Sized>(csprng: &mut R) -> SigningKey {
let mut secret = SecretKey::default();
csprng.fill_bytes(&mut secret);
Self::from_bytes(&secret)
}
pub fn try_generate<R: TryRngCore + TryCryptoRng + ?Sized>(csprng: &mut R) -> Result<SigningKey,<R as TryRngCore>::Error> {
let mut secret = SecretKey::default();
csprng.try_fill_bytes(&mut secret)?;
Ok(Self::from_bytes(&secret))
} It will offer some backward compatibility while aligning with |
https://docs.rs/rand_core/0.9.0/rand_core/trait.CryptoRng.html Also you can call |
I assume we can live with ff/group will get duplicate 0.8 rand until ff/group upgrades - unblocking us to adopt 0.9 ? |
Could you retarget |
Since it seems we have ended up in a bit of a holding pattern where everyone waits on everyone else to make the move to rand 0.9.x I went ahead and scoped out what would be needed for getting at least all the tests to compile. The changes needed can be viewed in this commit but it seemed impolite to open a second PR pretty much the same thing. @pinkforest please let me know how/if you would like to incorporate those changes, I'm happy to see this addressed in whatever way. Some observations:
|
You can get an OsRng.unwrap_err() ...which returns an
|
rand = "0.8" | ||
rand_core = { version = "0.6", default-features = false, features = ["getrandom"] } | ||
rand = "0.9" | ||
rand_core = { version = "0.9", default-features = false, features = ["getrandom"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rand_core = { version = "0.9", default-features = false, features = ["getrandom"] } | |
rand_core = { version = "0.9", default-features = false, features = ["os_rng"] } |
serde = { version = "1", default-features = false, optional = true, features = ["derive"] } | ||
zeroize = { version = "1", default-features = false, optional = true, features = ["zeroize_derive"] } | ||
|
||
[dev-dependencies] | ||
bincode = "1" | ||
criterion = "0.5" | ||
rand_core = { version = "0.6", default-features = false, features = ["getrandom"] } | ||
rand_core = { version = "0.9", default-features = false, features = ["getrandom"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rand_core = { version = "0.9", default-features = false, features = ["getrandom"] } | |
rand_core = { version = "0.9", default-features = false, features = ["os_rng"] } |
Closing in favor of #777 |
Pending / Clarifications
Breaking/Minor (Opt-in): We need to implementTryCryptoRng
which needs API changes from current infallible API.Notes
rand::thread_rng
: renamed torng
<-- was renamedOsRng
does not seem to implementCryptoRng
? rust-random/rand#1561ThreadRng
andOsRng
implement diffTry/CryptoRng
traits rust-random/rand#1566rand::rng()
useOsRng
unlessthread_rng
is enabled? rust-random/rand#1545