decred / dcrd

Decred daemon in Go (golang).
https://decred.org
ISC License
731 stars 289 forks source link

uniform: Add internal uniform random package #3357

Closed jrick closed 2 months ago

jrick commented 2 months ago

Code adapted from dcrwallet's internal/uniformprng package, but modified to take any reader as a randomness source. This can be a CSPRNG, or crypto/rand.Reader.

The random reader is required to never panic. This will not be a concern when using crypto/rand on any modern operating system which provides non-blocking kernel entropy through a system call.

jrick commented 2 months ago

This is needed by mixclient which can't import the package from the main module without also having a circular require on the main module. Since it is only (at this point in time) going to be used by the mixing module, it will go under mixing/internal instead. Will be included as part of a future PR.