Douglas Crockford
2017-07-24
Srash64 might be a secure random number generator function.
It is an adaptation of Fash256.
This is an implementation in a mythical language.
def prime_11 := 11111111111111111027 def prime_9 := 9999999999999999961 def prime_8 := 8888888888888888881 def prime_7 := 7777777777777777687 def prime_6 := 6666666666666666619 def prime_5 := 5555555555555555533 def prime_4 := 4444444444444444409 def prime_3 := 3333333333333333271 # The state of the random number generator function is kept in 17 variables. var a_product: uint64 var a_sum: uint64 var b_product: uint64 var b_sum: uint64 var c_product: uint64 var c_sum: uint64 var d_product: uint64 var d_sum: uint64 var e_product: uint64 var e_sum: uint64 var f_product: uint64 var f_sum: uint64 var g_product: uint64 var g_sum: uint64 var h_product: uint64 var h_sum: uint64 var counter: uint64 def srash64_seed(seeds: array of 16 uint64) { # The srash64_seed function initializes the srash64 rng function's state. # The seed contains 1024 bits. a_product := seeds[0] a_sum := seeds[1] b_product := seeds[2] b_sum := seeds[3] c_product := seeds[4] c_sum := seeds[5] d_product := seeds[6] d_sum := seeds[7] e_product := seeds[8] e_sum := seeds[9] f_product := seeds[10] f_sum := seeds[11] g_product := seeds[12] g_sum := seeds[13] h_product := seeds[14] h_sum := seeds[15] counter := 0 } def srash64() { var a_high: uint64 var b_high: uint64 var c_high: uint64 var d_high: uint64 var e_high: uint64 var f_high: uint64 var g_high: uint64 var h_high: uint64 var a_low: uint64 var b_low: uint64 var c_low: uint64 var d_low: uint64 var e_low: uint64 var f_low: uint64 var g_low: uint64 var h_low: uint64 a_high ; a_low := (a_product xor counter) * prime_11 b_high ; b_low := b_product * prime_9 c_high ; c_low := c_product * prime_8 d_high ; d_low := d_product * prime_7 e_high ; e_low := e_product * prime_6 f_high ; f_low := f_product * prime_5 g_high ; g_low := g_product * prime_4 h_high ; h_low := h_product * prime_3 counter += 1 a_sum += a_high b_sum += b_high c_sum += c_high d_sum += d_high e_sum += e_high f_sum += f_high g_sum += g_high h_sum += h_high a_product := a_low xor h_sum b_product := b_low xor a_sum c_product := c_low xor b_sum d_product := d_low xor c_sum e_product := e_low xor d_sum f_product := f_low xor e_sum g_product := g_low xor f_sum h_product := h_low xor g_sum return ( ((a_product + e_product) xor (b_product + f_product)) + ((c_product + g_product) xor (d_product + h_product)) ) }