Determenistic seeding of LuaJIT PRNG from C code

  • From: Konstantin Olkhovskiy <lupus@xxxxxxxxxx>
  • To: luajit <luajit@xxxxxxxxxxxxx>
  • Date: Wed, 26 Mar 2014 20:21:10 +0400

Hi Mike, List,

There was some thread [1] not so long ago about PRNG.

On 02.05.2013, at 20:08, Mike Pall <mike-1305@...> wrote:
> [I could add support for seeding with a FFI 64 bit integer or even
> a binary string, if needed.]

I guess we need this functionality...

We have a binary string (acquired from main PRNG) and would like to seed
LuaJIT's PRNG with this string. Lua can get this binary string only via some
C struct member (i.e. int64_t or char[16]).

Deterministic behaviour is highly appreciated, as LuaJIT's PRNG will be
seeded by the same binary string from multiple machines and must yield
same sequence of pseudo random numbers (used in transaction log replay).

Are there any obvious ways of doing this determenistically?

I though of tonumber(<int64_t cdata>), but my concern is about roundings
and other floating point machinery that can kick in.

[1] http://comments.gmane.org/gmane.comp.lang.lua.luajit/2483

-- 
Regards,
Konstantin

Other related posts: