Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement efficient addition formula for affine points #947

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

VolodymyrBg
Copy link

This PR implements the efficient addition formula for affine points in short Weierstrass curves.

Previously, when adding two affine points, they were first converted to projective coordinates and then the general addition formula was used. This implementation directly computes the sum of two affine points using the specialized formula for z=1, which is more efficient.

The implementation includes:

  1. Direct addition formula for affine points
  2. Special case handling for infinity and point doubling
  3. A new double() method for affine points

This resolves the TODO comment in the affine.rs file.

This PR implements the efficient addition formula for affine points in short Weierstrass curves.

Previously, when adding two affine points, they were first converted to projective coordinates
and then the general addition formula was used. This implementation directly computes the sum
of two affine points using the specialized formula for z=1, which is more efficient.

The implementation includes:
1. Direct addition formula for affine points
2. Special case handling for infinity and point doubling
3. A new double() method for affine points

This resolves the TODO comment in the affine.rs file.
@VolodymyrBg VolodymyrBg requested review from a team as code owners February 27, 2025 19:55
@VolodymyrBg VolodymyrBg requested review from z-tech, Pratyush and mmagician and removed request for a team February 27, 2025 19:55
@Pratyush
Copy link
Member

This uses an inversion, and will be much slower.

@VolodymyrBg
Copy link
Author

@Pratyush
suggested one more variant

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