I am working on a library that allows me to work with elliptic curves. It is still at embryonic state, and so far it only consists of two classes, EllipticCurve and Point.
Right now I'm implementing the basic operations of existence, belonging, sum, reflection, etc.
Unfortunately, I'm stuck now that I have to implement the concept of zero, i.e., the point of the elliptic curve E crossing the line through P and -P, where P = (x,y) and -P = (x,-y). So, my question could be rephrased as "how do I implement a point at infinity?"
Here's part of the Point class so far:
public class Point implements Comparable<Point> {
private static final BigDecimal MINUSONE = new BigDecimal(-1);
private BigDecimal x;
private BigDecimal y;
private EllipticCurve e;
public Point(BigDecimal x, BigDecimal y, EllipticCurve e) {
if(x != null && y != null && e != null) {
if(liesOn(x,y,e)) {
this.x = x;
this.y = y;
this.e = e;
}
}
}
public Point reflect() {
return new Point(x,y.multiply(MINUSONE),e);
}
public Point add(Point o) {
if(this.e == o.getE()) {
if(this == o) {
return this.multiply(2);
}
if(o == this.reflect()) {
return /*THE INFAMOUS ZERO POINT*/;
}
BigDecimal a;
BigDecimal b;
/*
* computation I still haven't implemented
*/
return new Point(a,b,e);
}
}
/*
* other methods
*/
}
P.S.: I am aware of the existence of java.security.spec.EllipticCurve, but since I'm going to use this class mostly for mathematical purposes, I felt the need to create my personal library ex novo.