public EccPoint Add(EccPoint pointA, EccPoint pointB) { // Any point added to infinity is itself if (pointA.Infinity) { return(pointB); } // Any point added to infinity is itself if (pointB.Infinity) { return(pointA); } // Any point added to its inverse is infinity if (pointA.Equals(Negate(pointB))) { return(new EccPoint("infinity")); } // Cannot add two identical points, use Double instead if (pointA.Equals(pointB)) { return(Double(pointA)); } var numerator = _operator.Subtract(pointB.Y, pointA.Y); var denominator = _operator.Subtract(pointB.X, pointA.X); var lambda = _operator.Divide(numerator, denominator); var x = _operator.Subtract(_operator.Subtract(_operator.Multiply(lambda, lambda), pointA.X), pointB.X); var y = _operator.Subtract(_operator.Multiply(_operator.Subtract(pointA.X, x), lambda), pointA.Y); return(new EccPoint(x, y)); }
public EdPoint Add(EdPoint pointA, EdPoint pointB) { var numeratorX = _operator.Add(_operator.Multiply(pointA.X, pointB.Y), _operator.Multiply(pointA.Y, pointB.X)); var numeratorY = _operator.Subtract(_operator.Multiply(pointA.Y, pointB.Y), _operator.Multiply(CoefficientA, _operator.Multiply(pointA.X, pointB.X))); var denominatorMult = _operator.Multiply(CoefficientD, _operator.Multiply(_operator.Multiply(pointA.X, pointB.X), _operator.Multiply(pointA.Y, pointB.Y))); var denominatorX = _operator.Add(1, denominatorMult); var denominatorY = _operator.Subtract(1, denominatorMult); var x = _operator.Divide(numeratorX, denominatorX); var y = _operator.Divide(numeratorY, denominatorY); return(new EdPoint(x, y)); }