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

Noble-ed25519, does not handle the point at infinity in the toAffine method #99

Merged
merged 1 commit into from
Feb 19, 2024

Conversation

LeJamon
Copy link
Contributor

@LeJamon LeJamon commented Feb 19, 2024

In the current implementation of the toAffine method within the @noble-ed25519 library, there is an incorrect handling of the point at infinity O when transforming from projective to affine coordinates. Specifically, the point at infinity is incorrectly encoded as (0, 0) for the ed25519 curve.

if (this.is0()) return { x: 0n, y: 0n }; 

However, for the ed25519 curve, the point at infinity should be represented by (0, 1) in affine coordinates to satisfy the curve equation and ensure correct computations during export and import operations.

We can fix it by doing this :

if (this.equals(I)) return { x: 0n, y: 1n };

Solved with @Elli610

@paulmillr paulmillr merged commit 0bbce04 into paulmillr:main Feb 19, 2024
1 check passed
@@ -99,7 +99,7 @@ class Point { // Point in xyzt extende
}
toAffine(): AffinePoint { // converts point to 2d xy affine point
const { ex: x, ey: y, ez: z } = this; // (x, y, z, t) ∋ (x=x/z, y=y/z, t=xy)
if (this.is0()) return { x: 0n, y: 0n }; // fast-path for zero point
if (this.equals(I)) return { x: 0n, y: 1n }; // fast-path for zero point
Copy link
Owner

Choose a reason for hiding this comment

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

why is0 replaced with equals i?

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.

None yet

2 participants