Skip to content

perf: optimize point tripling#724

Closed
gbotrel wants to merge 7 commits intomasterfrom
perf/triple
Closed

perf: optimize point tripling#724
gbotrel wants to merge 7 commits intomasterfrom
perf/triple

Conversation

@gbotrel
Copy link
Copy Markdown
Collaborator

@gbotrel gbotrel commented Aug 19, 2025

Description

Optimize G1Jac tripling (20% faster for bn254, 10% for bls12-377).

benchmark                   old ns/op     new ns/op     delta
BenchmarkG1JacTriple-32     290           233           -19.49%
BenchmarkG2JacTriple-32     546           542           -0.73%

@gbotrel gbotrel requested review from Copilot and yelhousni August 19, 2025 20:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes the point tripling operation for G1 and G2 Jacobian coordinates in elliptic curve cryptography, achieving 20% faster performance for bn254 and 10% for bls12-377 curves.

  • Refactors the Triple method implementation with clearer step-by-step structure and improved documentation
  • Adds comprehensive test coverage for the Triple method including correctness tests against double+add and benchmarking
  • Implements optimized helper functions for multiplication by 3 and 4, leveraging specialized fp.MulBy3 where available

Reviewed Changes

Copilot reviewed 34 out of 34 changed files in this pull request and generated no comments.

File Description
internal/generator/ecc/template/point.go.tmpl Template optimization with step-by-step algorithm and conditional MulBy3 usage
internal/generator/ecc/template/tests/point.go.tmpl Template for Triple test functions and benchmarks
Multiple ecc/*/g1.go and g2.go files Generated optimized Triple implementations across all curve types
Multiple ecc/*/g1_test.go and g2_test.go files Generated test coverage for Triple method validation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@gbotrel gbotrel requested a review from ThomasPiellard August 20, 2025 14:31
gbotrel added a commit that referenced this pull request Aug 25, 2025
Base automatically changed from feat/triple to master August 25, 2025 16:40
@gbotrel gbotrel closed this Aug 25, 2025
@ivokub ivokub deleted the perf/triple branch November 27, 2025 10:32
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.

3 participants