Skip to content

Commit 1333751

Browse files
committed
feat(common): added a comment explaning the swap to SysRng
1 parent 5d6559f commit 1333751

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

mithril-common/src/crypto_helper/ed25519.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ impl Ed25519Signer {
5050

5151
/// [Ed25519Signer] non deterministic
5252
pub fn create_non_deterministic_signer() -> Self {
53+
// `rand_core`'s `OsRng` was removed and replaced by `getrandom::SysRng`. `OsRng` was
54+
// a wrapper around `getrandom` internally so the functionality does not change.
55+
// `SysRng` reads from the same OS entropy sources as before (e.g. the `getrandom`
56+
// syscall on Linux, `ProcessPrng` on Windows, `getentropy` on macOS) under
57+
// the same documented security guarantee.
58+
//
59+
// `SysRng` only implements the fallible `TryRng`/`TryCryptoRng` (an OS entropy call can,
60+
// in principle, fail). `UnwrapErr` makes `SysRng` Infallible to fit the `generate` bounds.
61+
// It can panic on failure in the same way `OsRng` did so the chance of failure stays the
62+
// same.
5363
let rng = UnwrapErr(SysRng);
5464
Self::create_test_signer(rng)
5565
}

0 commit comments

Comments
 (0)