Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Incorrect type conversion in GetCommitteeID #501

Open
AKorpusenko opened this issue Sep 16, 2024 · 0 comments · May be fixed by #503
Open

bug: Incorrect type conversion in GetCommitteeID #501

AKorpusenko opened this issue Sep 16, 2024 · 0 comments · May be fixed by #503
Labels
bug Something isn't working

Comments

@AKorpusenko
Copy link
Contributor

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)
}
@AKorpusenko AKorpusenko added the bug Something isn't working label Sep 16, 2024
@MatheusFranco99 MatheusFranco99 linked a pull request Sep 17, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant