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

bounds check comparing polynomials #56

Merged
merged 3 commits into from
Feb 21, 2024
Merged

Conversation

CluEleSsUK
Copy link

I came across a panic here in my travels if somebody constructs an invalid PubPoly for comparison.
Tbh this is not exhaustive, there are probably a bunch of other places where this could blow up, I only fixed this one

@CluEleSsUK
Copy link
Author

In principle, two invalid polynomials could be equal if they don't have enough commits (though it would panic). I don't think this is a valid use case, hence just checking the threshold against the commit length

share/poly.go Outdated
@@ -387,6 +387,11 @@ func (p *PubPoly) Equal(q *PubPoly) bool {
return false
}
b := 1

if len(p.commits) < p.Threshold() || len(q.commits) < p.Threshold() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if p.Threshold() != q.Threshold() ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assumed they just wouldn't be equal, but I guess this might not be the case if q has strictly more commits than p

share/poly.go Show resolved Hide resolved
@AnomalRoil AnomalRoil merged commit 4417fb6 into master Feb 21, 2024
1 check passed
@AnomalRoil AnomalRoil deleted the fix/panic-bounds-check branch February 21, 2024 11:41
Robingoumaz pushed a commit to Robingoumaz/kyber-drand that referenced this pull request Apr 4, 2024
* bounds check when comparing polynomials
* added extra check of threshold
* fixing comment on PubPoly Equal being constant time

---------

Co-authored-by: Yolan Romailler <anomalroil@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants