#random #numbers #randomness #getrandom #generator #panic #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

#514 in Cryptography

Download history 50904/week @ 2024-08-14 44671/week @ 2024-08-21 56205/week @ 2024-08-28 55305/week @ 2024-09-04 58589/week @ 2024-09-11 57001/week @ 2024-09-18 52543/week @ 2024-09-25 62887/week @ 2024-10-02 59982/week @ 2024-10-09 62235/week @ 2024-10-16 60909/week @ 2024-10-23 60304/week @ 2024-10-30 60030/week @ 2024-11-06 54247/week @ 2024-11-13 50716/week @ 2024-11-20 40695/week @ 2024-11-27

220,894 downloads per month
Used in 737 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

~235KB