[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MirageOS-devel] random number interface
On 05/24/2016 10:49 AM, Kia wrote:
I am working on an NTP client/server implementation in ocaml for mirageos
(https://matildah.github.io/posts/2016-05-23-ntp-status.html) and I need to
have access to random numbers -- is
https://github.com/mirage/mirage/blob/master/types/V1.mli#L63 the right way for
for a mirageos library to get random numbers or is this out of date/deprecated?
Is there a reference/example for how a library can use the random number
generation module in mirage?
Hi Kia,
The Random module uses the OCaml runtime's random module. Here's
the header on that module:
" Pseudo-random number
generator
This is a lagged-Fibonacci F(55, 24, +) with a modified
addition
function to enhance the mixing of
bits.
If we use normal addition, the low-order bit fails tests 1 and
7
of the Diehard test suite, and bits 1 and 2 also fail test
7.
If we use multiplication as suggested by Marsaglia, it doesn't
fare
much
better.
By mixing the bits of one of the numbers before addition (XOR
the
5 high-order bits into the low-order bits), we get a generator
that
passes all the Diehard tests.
"
Seeding: "Initialize the generator with a random seed chosen in a
system-dependent way. If /dev/urandom is
available on the host machine, it is used to provide a highly random
initial seed. Otherwise, a less random seed is computed from system
parameters (current time, process IDs)."
If this is sufficient for your needs, Random is indeed the way to
go. If you need better guarantees, it might be a good idea to talk
with the folks who built ocaml-nocrypto.
Thanks,
Mindy
|
_______________________________________________
MirageOS-devel mailing list
MirageOS-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel
|