public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Replace /dev/random input mix polynomial with Brent's xorgen?
@ 2013-12-14  9:06 George Spelvin
  2013-12-14 19:23 ` Theodore Ts'o
  0 siblings, 1 reply; 14+ messages in thread
From: George Spelvin @ 2013-12-14  9:06 UTC (permalink / raw)
  To: tytso; +Cc: linux, linux-kernel

Richard Brent extended some efficient XOR-based PRNGs designed by George
Marsaglia into a family of "xorgen" generators which are efficent,
non-sparse, maximal-period polynomials of length 64, 128, 256,... 4096
bits.

(It ends there because proving period 2^n-1 requires knowing the
factorization of 2^n-1, and 2^8192-1 = (2^4096+1)*(2^2048+1)*...*(2^1+1).
The factorization of 2^4096+1 = F_12 is currently stuck on an 1133-digit
composite residue; see http://caramel.loria.fr/f12.txt)

http://maths-people.anu.edu.au/~brent/pub/pub224.html
"Some long-period random number generators using shifts and xors",

Related background papers:
http://www.jstatsoft.org/v08/i14/paper
"Xorshift RNGs"
http://maths-people.anu.edu.au/~brent/pub/pub218.html
"Note on Marsaglia's xorshift RNGs"

Anyway, the algorithm boils down to

t1 = x[i-r];	t2 = x[i-s];
t1 ^= t1 << a;	t2 ^= t2 << c;
t1 ^= t1 >> b;	t2 ^= t2 >> d;
x[i] = t1 ^ t2;

For various constants r = 2..128, s < r, and shifts a, b, c and d.
Both 32- and 64-bit versions are included.

This is both more efficient and (especually using 64-bit words) more
thorough than the current code, for sizes up to 4096 bits.  Although the
current code has tables for larger pools, everything larger than 32x128 =
4096 bits is currenty commented out and not used.

Would you be interested in a patch to revise _mix_pool_bytes()?

I'm also thinking of revising the input rotate-by-7 to use
Marsaglia's original xorshift as a whitener.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-12-16 15:03 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-14  9:06 Replace /dev/random input mix polynomial with Brent's xorgen? George Spelvin
2013-12-14 19:23 ` Theodore Ts'o
2013-12-14 21:55   ` George Spelvin
2013-12-15  2:21     ` Theodore Ts'o
2013-12-15  8:34       ` George Spelvin
2013-12-15 22:19         ` Theodore Ts'o
2013-12-16  4:22           ` George Spelvin
2013-12-16  6:43             ` Theodore Ts'o
2013-12-16  6:49               ` Theodore Ts'o
2013-12-16 15:03               ` George Spelvin
2013-12-15 20:03   ` Greg Price
2013-12-15 22:09     ` George Spelvin
2013-12-16  0:32       ` Greg Price
2013-12-16  6:53         ` George Spelvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox