1

I'm interested int the PRNG algorithm that tezos uses for drawing baking rights. It is vaguely mentioned in the docs as a CSPRNG (Cryptographically secure pseudorandom number generator) seeded with a random seed generated from the revealed nonces. But that is all we get.

Can anyone provide some explanation how the mentioned CSPRNG works? Did they use a known algorithm or developed their own?

1 Answer 1

3

tl;dr it is home-made CSPRNG based on repeatedly hashing an initial seed with Blake2b.

Details: The interface of this CSPRNG can be found in the protocol here, and the implementation here. (Optionally, you can read the interface here, but the formatting is messed up.)

The function take generates a new random value using State_hash:

let take (S state) =
  let b = State_hash.to_bytes state in
  let h = State_hash.hash_bytes [b] in
  (State_hash.to_bytes h, S h)

State_hash uses Blake2b internally.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.