chickadee » tweetnacl » current-entropy-port

current-entropy-portparameter

An input port connected to an entropy source for key generation.

When compiled on a unix system, this parameter is by default bound to the result of (open-input-file "/dev/random"). When compiled on a windows system, the default value of the parameter is a custom input port that returns bytes produced by RtlGenRandom. On other systems the default value of the parameter will be #f and you will have to set it explicitly before key generation functions can be used.

To speed up key generation it can be useful to set current-entropy-port to a pseudo-random stream only seeded initially from the system entropy source:

 (current-entropy-port (open-random-stream (make-random-stream-key) (make-u8vector random-stream-noncebytes 0)))