Expand description
Functions for leader selection based on the DRB.
The algorithm we use is:
Initialization:
- obtain
drb: [u8; 32]
from the DRB calculation - sort the stake table for a given epoch by
xor(drb, public_key)
- generate a cdf of the cumulative stake using this newly-sorted table, along with a hash of the stake table entries
Selecting a leader:
- calculate the SHA512 hash of the
drb_result
,view_number
andstake_table_hash
- find the first index in the cdf for which the remainder of this hash modulo the
total_stake
is strictly smaller than the cdf entry - return the corresponding node as the leader for that view
Structs§
Functions§
- cyclic_
xor 🔒 - Calculate
xor(drb.cycle(), public_key)
, returning the result as a vector of bytes - generate_
stake_ cdf - Generate the stake table CDF, as well as a hash of the resulting stake table
- select_
randomized_ leader - select the leader for a view