Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new Triple method for computing [3]P (scalar multiplication by 3) in Jacobian coordinates for j=0 elliptic curves. The implementation follows the XuHanTian24 paper and provides significant performance improvements over the traditional double-and-add approach, reducing costs from 10S+13M to 4S+6M.
- Adds optimized
Triplemethod for all j=0 curves (all supported curves except STARK) - Integrates
Tripleinto existing scalar multiplication methods and precomputation tables - Optimizes several curve-specific operations like
mulBySeedandClearCofactorto useTriple
Reviewed Changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated 11 comments.
| File | Description |
|---|---|
| internal/generator/ecc/template/tests/point.go.tmpl | Adds test property verifying [3]P == [2]P+P |
| internal/generator/ecc/template/point.go.tmpl | Implements Triple method and integrates it into various multiplication routines |
| Multiple curve files (g1.go, g2.go, g1_test.go, g2_test.go) | Generated implementations of Triple method and optimizations for specific curves |
9 tasks
ThomasPiellard
previously approved these changes
Aug 22, 2025
ThomasPiellard
approved these changes
Aug 25, 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
This PR introduces Jacobian Triple for
j=0curves, i.e.[3]Pin Jacobian coordinates for curves in the formy^2=x^3+b. This works for all curves supported by gnark-crypto (bothG1andG2) except STARK curve. We follow [XuHanTian24]. The cost is4S+6Minstead of10S+13M(double+add). The PR also usesTriplein several places across the curves packages.Type of change
How has this been tested?
Testing
[3]P == [2]P+Pand all the methods which now useTriplemethod.How has this been benchmarked?
e.g. BLS12-381 on my MBA M1:
Checklist:
golangci-lintdoes not output errors locally