This PR uses the lazy_static crate to use a persistent OsRng instance in randombytes.rs. This lets of avoid creating a new OsRng on every randombytes call (i.e. opening/closing /dev/urandom on Linux or creating/destroying a crypto context on Windows).
In the future, we may want to consider implementing this in a custom way to be more efficient since we don't actually need the atomicity checks going on here, since tweetnacl itself is threadsafe.
This PR uses the lazy_static crate to use a persistent
OsRng
instance inrandombytes.rs
. This lets of avoid creating a newOsRng
on everyrandombytes
call (i.e. opening/closing /dev/urandom on Linux or creating/destroying a crypto context on Windows).In the future, we may want to consider implementing this in a custom way to be more efficient since we don't actually need the atomicity checks going on here, since
tweetnacl
itself is threadsafe.This PR closes #23