MCPcopy
hub / github.com/canopy-network/canopy / FormatInputIntoSeed

Function FormatInputIntoSeed

lib/consensus.go:833–845  ·  view source on GitHub ↗

FormatInputIntoSeed() returns the 'seed data' for the VRF function `seed = lastProposerAddresses + height + round`

(lastProposerAddresses [][]byte, rootHeight, height, round uint64)

Source from the content-addressed store, hash-verified

831// FormatInputIntoSeed() returns the 'seed data' for the VRF function
832// `seed = lastProposerAddresses + height + round`
833func FormatInputIntoSeed(lastProposerAddresses [][]byte, rootHeight, height, round uint64) []byte {
834 // create a string to hold the vrf input
835 var input string
836 // for each proposer address
837 for _, address := range lastProposerAddresses {
838 // add to the string using hex representation with a delimiter
839 input += BytesToString(address) + "/"
840 }
841 // add the height and round to the end of the input
842 input += fmt.Sprintf("%d/%d/%d", rootHeight, height, round)
843 // hash the result
844 return crypto.Hash([]byte(input))
845}

Callers 4

TestStartElectionPhaseFunction · 0.92
VerifyCandidateFunction · 0.92
VRFFunction · 0.92
WeightedPseudorandomFunction · 0.85

Calls 2

HashFunction · 0.92
BytesToStringFunction · 0.85

Tested by 1

TestStartElectionPhaseFunction · 0.74