Skip to content

bounds check comparing polynomials#56

Merged
AnomalRoil merged 3 commits intomasterfrom
fix/panic-bounds-check
Feb 21, 2024
Merged

bounds check comparing polynomials#56
AnomalRoil merged 3 commits intomasterfrom
fix/panic-bounds-check

Conversation

@CluEleSsUK
Copy link
Copy Markdown

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
Copy Markdown
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

Comment thread share/poly.go Outdated
}
b := 1

if len(p.commits) < p.Threshold() || len(q.commits) < p.Threshold() {
Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread share/poly.go
@AnomalRoil AnomalRoil merged commit 4417fb6 into master Feb 21, 2024
@AnomalRoil AnomalRoil deleted the fix/panic-bounds-check branch February 21, 2024 11:41
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.

2 participants