indutny / elliptic

Fast Elliptic Curve Cryptography in plain javascript
1.66k stars 359 forks source link

How does point comparison work for the identity / point at infinity? #310

Open matthiasgeihs opened 10 months ago

matthiasgeihs commented 10 months ago

Point equality is implemented as: https://github.com/indutny/elliptic/blob/43ac7f230069bd1575e1e4a58394a512303ba803/lib/elliptic/curve/mont.js#L163-L165

The identity (aka point at infinity) is any point that has 0 in its z-coordinate: https://github.com/indutny/elliptic/blob/43ac7f230069bd1575e1e4a58394a512303ba803/lib/elliptic/curve/mont.js#L77-L80

How would point comparison give the correct result when comparing against the point at infinity?