Feat: add purego ext 5 over koalabear and babybear fields#778
Open
Feat: add purego ext 5 over koalabear and babybear fields#778
Conversation
| var r fr.Element | ||
| switch alpha { | ||
| case 0: | ||
| return r |
There was a problem hiding this comment.
Bug: evalAt returns zero instead of a0 for alpha=0
The evalAt function evaluates a polynomial at a given value alpha, but the case 0 branch returns a zero-initialized r instead of a.A0. Mathematically, A(0) equals a0, not zero. While the current implementation avoids this code path by using u[0].Set(&a.A0) directly with a comment // A(0), the function's behavior contradicts its documented contract if someone were to call evalAt(a, 0). The same issue exists in both babybear and koalabear implementations.
Additional Locations (1)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
We might need extension 5 over koalabear instead of 4 for higher security. This PR implements purego ext 5 over koala/baby bears, using naive, Montgomery-5 and ElMraber-Guillevic-Ionica algorithms.
Type of change
How has this been tested?
Tests implemented in e5_direct_test.go in koalabear and babybear packages.
How has this been benchmarked?
So far for multiplication, Montgomery-5 is the fastest (also compared to Montgomery-6 and Toom-3/Karatsuba in #772)
Checklist:
golangci-lintdoes not output errors locallyNote
Introduce
E5D(𝔽r⁵) for koalabear and babybear with naive, Montgomery-5, and interpolation mul; update docs, generator, and add tests/benchmarks.E5D(𝔽r⁵) implementation inextensions/e5_direct.gowithAdd/Sub/Double/Mul/Square, including naive,mulMontgomery5, andmulElMGuiIon5algorithms plus reduction rules (w^5=2for babybear,w^5=w^2-1for koalabear).extensions/e5_direct_test.govalidating algorithms and receiver behavior.extensions/doc.goanddoc.go.tmplto document extension-5 definitions for babybear and koalabear.e5_direct.goand tests for bear fields and rungoimportsinrunFormatters.Written by Cursor Bugbot for commit 028b3ac. This will update automatically on new commits. Configure here.