Use OsRng when generating a new Mnemonic - #105
Merged
Merged
Conversation
tankyleo
force-pushed
the
2026-08-use-osrng
branch
from
August 6, 2026 01:23
19d4160 to
f464135
Compare
Contributor
Author
|
I regenerated |
tnull
reviewed
Aug 6, 2026
tnull
left a comment
Collaborator
There was a problem hiding this comment.
Looks good, but can we do the dependency bump and the switch to OsRng in two separate commits?
In the following commit, we will switch the default RNG used to generate the `Mnemonic` from `rand::rngs::ThreadRng` to `rand::rngs::OsRng`. The rand 0.7 release shipped `OsRng` with a new constructor, so instead of handling the different constructors across versions 0.6 and 0.7+, we choose to bump the minimum rand version supported to 0.7. To reproduce the new `Cargo-minimal.lock`: ``` mv Cargo-minimal.lock Cargo.lock cargo +1.41.1 update --package "rand" --precise "0.7.0" cargo +1.41.1 update --package "rand" --precise "0.7.0" cargo +1.41.1 update --package "libc" --precise "0.2.151" cargo +1.41.1 update --package "ppv-lite86" --precise "0.2.17" mv Cargo.lock Cargo-minimal.lock ```
`ThreadRng` *should* be fine, but we are paranoid, and we do not need mnemonic generation to be fast, so we prioritize security and use `OsRng` by default to generate a new `Mnemonic`.
tankyleo
force-pushed
the
2026-08-use-osrng
branch
from
August 8, 2026 15:56
f464135 to
87bd59d
Compare
Contributor
Author
|
@tnull I've addressed your comment thank you. I also revisited how I create the new |
tnull
approved these changes
Aug 10, 2026
tnull
left a comment
Collaborator
There was a problem hiding this comment.
Thanks! LGTM!
Talked to other maintainers in the meantime, and we might be good to bump rand/MSRV even further, but that doesn't need to happen in this PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ThreadRngshould be fine, but we are paranoid, and we do not need mnemonic generation to be fast, so we prioritize security and useOsRngby default to generate a newMnemonic.Raise the minimum supported rand version to 0.7, the earliest release with unit-style
OsRngconstruction, while preserving Rust 1.41.1 compatibility through the MSRV dependency pins.