private static MyPoint Add(MyPoint leftOperand, MyPoint rightOperand) { if (leftOperand.IsInfinite) { return(rightOperand); } if (rightOperand.IsInfinite) { return(leftOperand); } var curve = leftOperand.Curve; var lambda = GetLambdaForAddition(leftOperand, rightOperand) % curve.Prime; var newX = (lambda ^ 2) - leftOperand.X - rightOperand.X; newX = newX % curve.Prime; var newY = lambda * (leftOperand.X - newX) - leftOperand.Y; newY = newY % curve.Prime; var newPoint = new MyPoint(newX, newY, curve); newPoint.IsOnCurve(); return(newPoint); }
public MyPoint Negate() { var point = new MyPoint(X, Y.Negate(), Curve); point.IsOnCurve(); return(point); }
private MyPoint Double() { if (IsInfinite) { return(this); } var lambda = GetLambdaForDoubling() % Curve.Prime; var newX = (lambda ^ 2) - X * 2; newX = newX % Curve.Prime; var newY = (lambda * (X - newX)) - Y; newY = newY % Curve.Prime; var newPoint = new MyPoint(newX, newY, Curve); newPoint.IsOnCurve(); return(newPoint); }