lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> -----Original Message-----
> From: Gerhard Sittig <gerhard.sittig@gmx.net>
> Sent: Thursday, March 16, 2023 2:32 PM
> To: Lua mailing list <lua-l@lists.lua.org>
> Subject: Re: Entropy in the implementation of Lua
> 
> On Thu, 2023-03-16 at 06:40 +0100, bil til wrote:
> >
> > Am Mi., 15. März 2023 um 20:28 Uhr schrieb Roger Leigh
> <rleigh@codelibre.net>:
> > >
> > > [ ... replace this with a direct call to a hardware RNG and get a
> > >   truly random number straight from the hardware. ...]
> >
> > ... this I tried also, but it is not so easy, as the RNG module is
> > analogue and thus "a bit slow". It needs startup-time in millisecond
> > range, and also the random values are not created "super-high-speed"
> > (at least not in "digital clock speed" of the controller - I felt a
> > bit unsure what would happen if Lua would ask for many random values
> > one after each other - I would not like to invoke "delay waiting
> > states" then (but I did NOT investigate this further so far)).
> 
> But isn't the point that you don't keep draining random numbers from the
> external hardware that is slow to generate them (the reason being that you
> get something really random, which is what you want in that specific case)?
> 
> That's why you have a pseudo RNG in the software, and _seed_ that from
> something with much better entropy. Results in the fast(er) generation of
> GoodEnough(TM) random numbers at an acceptable cost. Or did I miss
> something?

Yes, my initial implantation is being very naïve and slow here, and I would definitely be better off using it as a random seed.  I've yet to profile it properly to see how frequently it is called in practice, and I might be in for a nasty surprise!

Kind regards,
Roger