Implement `RandomCoin` seeding from `rand::rng`
- Dominant language
- Rust
- Stars
- 772
- Forks
- 352
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 93
Description
Lots of test code in protocol and miden-node code needs to currently initialize a `RandomCoin` and does it roughly as:
```rust
let auth_seed: [u64; 4] = rng.random();
let mut coin = RandomCoin::new(Word::from(auth_seed.map(Felt::new_unchecked)));
```
This is rather cumbersome and should ideally be as easy as:
```rust
let coin = RandomCoin::with_rand_rng();
```
This would be a `std`-gated method and could be:
```rust
impl RandomCoin {
fn with_rand_rng() -> RandomCoin {
let mut rng = rand::rng();
let mut bytes = vec![0u8; Word::VALUE_SIZE];
rng.fill(&mut bytes[..]);
let seed = Word::from_random_bytes(&bytes).expect("failed to generate random value");
RandomCoin::new(seed)
}
```
Maybe there's a better name for this method.
Contributor guide
Assessment
This issue has not been assessed yet.