#random #numbers #getrandom #randomness #generator #verifier

no-std getrandom_or_panic

Implements a RngCore which panics unless getrandom exists

2 releases

0.0.3 Nov 21, 2023
0.0.2 Nov 21, 2023
0.0.1 Nov 21, 2023

#500 in Cryptography

Download history 21982/week @ 2024-01-05 26450/week @ 2024-01-12 33266/week @ 2024-01-19 31516/week @ 2024-01-26 28283/week @ 2024-02-02 29093/week @ 2024-02-09 37524/week @ 2024-02-16 38308/week @ 2024-02-23 33663/week @ 2024-03-01 34387/week @ 2024-03-08 36890/week @ 2024-03-15 39740/week @ 2024-03-22 46476/week @ 2024-03-29 51055/week @ 2024-04-05 45961/week @ 2024-04-12 33039/week @ 2024-04-19

182,559 downloads per month
Used in 651 crates (via schnorrkel)

BSD-3-Clause

4KB

getrandom_or_panic

Addresses one minor conundrum in cryptography crates:

We want end user signers and provers to dependend directly upon getrandom for system randomness, so that users cannot supply insecure random number generators.

We need verifiers to run in contexts without system randomness though, like block chains.

We'd ideally seperate provers and verifiers using features, but doing so becomes tricky as crates become more complex, and makes insecure backends for getrandom tempting.

Instead, we pretend that system randomness exists to satisfy the compiler, but panic if called without getrandom. You could still provide an insecure getrandom, but now you've been warnned about this footgun.


lib.rs:

Returns OsRng with getrandom, or a CryptoRng which panics without getrandom.

Dependencies

~230KB