Commit b56c0f3
committed
fix(keypairs): use OsRng directly for seed entropy (#286)
`generate_seed` was seeding an `Hc128Rng` stream cipher from the OS once
per call, then filling the seed buffer from that cipher's keystream.
HC-128 is a recognised eSTREAM-portfolio cipher, but the choice means a
single compromise of the initial entropy snapshot inside the process
exposes every wallet generated during the process lifetime — and it
departs from what xrpl-py and xrpl.js use for secret-material
generation.
Replace `rand_hc::Hc128Rng::from_entropy()` with `rand::rngs::OsRng`,
which reads from the OS entropy pool on each call. Drop the
`rand_hc = "0.3.1"` dependency from `Cargo.toml` (it had no other call
sites) and remove the now-unused `use rand::SeedableRng;`.
Adds `generate_seed_without_entropy_produces_distinct_outputs` — pins
the property that two consecutive `generate_seed(None, None)` calls
return different seeds. Trivially true with `OsRng` but worth locking
so any future RNG swap is forced to preserve it.
The existing `generate_seed(Some(TEST_BYTES), ...)` deterministic-path
tests are unchanged.1 parent b154d4e commit b56c0f3
2 files changed
Lines changed: 22 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
| |||
105 | 104 | | |
106 | 105 | | |
107 | 106 | | |
108 | | - | |
109 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
110 | 114 | | |
111 | 115 | | |
112 | 116 | | |
| |||
302 | 306 | | |
303 | 307 | | |
304 | 308 | | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
305 | 324 | | |
306 | 325 | | |
307 | 326 | | |
| |||
0 commit comments