I am writing code for Elliptic Curve Cryptography. I have a class class EllipticCurvePoint
.
class EllipticCurvePoint{
FieldElement x, y;
};
I need to support point-at-infinity (which should behave as if it is an object of type EllipticCurvePoint
). Only thing I can think of is to reserve (-1, -1) for this but x and y can assume values only from {0, 1, ..., p-1} (p being the Field
they belong to). If I want to represent it this way, I would need to add support for -1 in the classes FieldElement
and Field
too.
I have also overloaded the + and the * operators which work perfectly fine for other points. But I cannot think of a way to represent point-at-infinity which can work homogeneously with the rest of the code and I wouldn't have to change the parent classes(Field
and FieldElement
).
Is there any elegant way to achieve this? Thanks a lot for your time!
is_infinity
flag. – SEJPM Oct 13 '19 at 11:44