ssvlabs/ssv-spec

bug: Incorrect type conversion in GetCommitteeID

Opened this issue · 0 comments

In func GetCommitteeID in types/committee_id.go contains a potential overflow bug conversion of uint64 to uint32 as OperatorID type is uint64, but PutUint32 is used.

// Return a 32 bytes ID for the cluster of operators
func GetCommitteeID(committee []OperatorID) CommitteeID {
	// sort
	sort.Slice(committee, func(i, j int) bool {
		return committee[i] < committee[j]
	})
	// Convert to bytes
	bytes := make([]byte, len(committee)*4)
	for i, v := range committee {
		binary.LittleEndian.PutUint32(bytes[i*4:], uint32(v))
	}
	// Hash
	return sha256.Sum256(bytes)
}