Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize a predictable RNG #258

Open
dinosaure opened this issue Feb 8, 2025 · 1 comment
Open

Initialize a predictable RNG #258

dinosaure opened this issue Feb 8, 2025 · 1 comment

Comments

@dinosaure
Copy link
Member

I think there is still a use where you want to initialize the RNG so that it produces a predictable output. Typically, before the API change, it was possible to initialize the RNG with Fortuna and a seed. I think that this type of usage is still valid and that the deprecation on Mirage_crypto_unix.initialize should be removed. WDYT?

@hannesm
Copy link
Member

hannesm commented Feb 11, 2025

I'm not sure I understand the demand for a "predictable RNG", but you can always:

let () =
  let g = Mirage_crypto_rng.create ~seed:"private" (module Mirage_crypto_rng.Fortuna) in
  Mirage_crypto_rng.set_default_generator g

Now, with Mirage_crypto_rng_unix.initialize -- there was no predictability given, since that used CPU instructions & whirwhind & getrandom for an initial seed.

Be aware that the set_default_generator is a global mutable cell, thus any other library may set it. To really ensure using the predictable RNG you want to have, pass the g explicit to generate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants