paulmillr / noble-ed25519

Fastest 4KB JS implementation of ed25519 signatures
https://paulmillr.com/noble
MIT License
420 stars 51 forks source link

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

Closed LeJamon closed 8 months ago

LeJamon commented 8 months ago

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