Closed sisyphusSmiling closed 1 year ago
I suggest the following way to "mix" the seed and salt and extract the Xorshit128+ seed.
I assume we have the following interface to create a Xorshit128+ instance:
NewXorshift128plus(seed [16]byte) : PRGInstance
and we would like to define the function:
NewPRG(source [32]byte, salt []byte) : PRGInstance // salt can be of arbitrary size
NewPRG(source [32]byte, salt []byte) : PRGInstance {
tmp = concat(source, salt)
hash = sha3_256(tmp) // hash is of size 32
seed = hash[0:16] // seed is of size 16
prg = NewXorshift128plus(seed)
return prg
}
some comments on the design:
Closed by #6 and #4
Related conversation: https://github.com/onflow/random-coin-toss/pull/4#discussion_r1378134981
Xorshit128+ typically uses 16 bytes, but the source of randomness we have available is 32 plus an 8 byte salt. As such, we'll need to update the current PRG implementation.