Just for the sake of learning, I'm attempting to write an ECDSA implementation in Java.
I have what I believe is a correct implementation for point addition and doubling, but I'm not sure how to implement point multiplication - Every online description I've found says to use an algorithm like this:
public static Point pointMultiply(BigInteger kin, Point a, Curve curve) {
Point r = new Point(BigInteger.ZERO, BigInteger.ONE);
BigInteger k = kin.mod(curve.getN());
int length = k.bitLength();
byte[] binarray = new byte[length];
for(int i = 0; i < length; i++) {
binarray[i] = k.mod(BigInteger.TWO).byteValue();
k = k.divide(BigInteger.TWO);
}
for(int i = length - 1; i >= 0; i--) {
r = pointAdd(r, r, curve);
if(binarray[i] == 1) {
r = pointAdd(r, a, curve);
}
}
return r;
}
Except all of those descriptions define r as the point at infinity. That's great, except my point doubling/adding code requires actual values in order to operate on the point. How do I find an actual value for that point so I can manipulate it, and if there is no defined value, how would I implement point multiplication?
Most of the descriptions of the point at infinity I've found say that it either isn't a real point and is some sort of abstract thing (in which case I don't understand how one can manipulate it) or that it has coordinates of (0,1), which does not give me a correct pubkey when I test it against BouncyCastle.