public static Point CalculateMultiplication(this EllypticCurve curve, Point g, BigInteger scalar) { var binary = scalar.ToBinaryString(); binary = binary.TrimStart('0'); var p = new Point(g.XCoordinate, g.YCoordinate); for (var i = 1; i < binary.Length; i++) { bool add = binary[i] == '1'; p = curve.CalculateDoubling(p); if (add) { p = curve.CalculateAddition(p, g); } } return(p); }
public static Point CalculateDoubling(this EllypticCurve curve, Point p) { return(curve.CalculateAddition(p, p)); }