Conversation
gbotrel
approved these changes
Dec 15, 2025
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
Montgomery in [1] presented a formula for multiplying quintic polynomials that needs one less multiplication than Karatsuba, but not much was said about the number of additions. In [2] the authors adapt this formula to compute the multiplication in direct sextic extensions Fp6. They report in Appendix A.1 a cost of
17M + 143A + 5B, whereM,A,Bstand for multiplication, addition and multiplication by the sextic non-residue β. In the case of BW6-761 β=4 soB=2Aand the overall cost is17M + 153A. The previous gnark-crypto implementation was using17M + 222A. In this PR we implement the product in17M + 130A.Type of change
How has this been tested?
Consistency between direct extension and 2-3 tower multiplications.
How has this been benchmarked?
Checklist:
golangci-lintdoes not output errors locallyNote
Replaces E6D.Mul with an optimized Montgomery-6 implementation and introduces a direct Montgomery-6 squaring routine, with corresponding property tests and benchmarks.
ecc/bw6-761/internal/fptower/e6_direct.go):mulMontgomery6and reimplement with a staged, 17M/low-additions Montgomery-6 algorithm.squareMontgomery6(direct Montgomery-6 squaring) plussquareTowerhelper;Squarecurrently uses tower path.SetOnecomment.ecc/bw6-761/internal/fptower/e6_direct_test.go):BenchmarkE6DSquareTowerandBenchmarkE6DSquareMontgomery6; keep mul benchmark using Montgomery-6.Written by Cursor Bugbot for commit 029b8fe. This will update automatically on new commits. Configure here.