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));
        }
Exemple #2
0
        public EccPoint Double(EccPoint point)
        {
            if ((point.X == 0 && point.Y == 0) || point.Infinity)
            {
                return(point);
            }

            if (point.Y == 0)
            {
                throw new ArgumentException("Cannot double a point with y = 0");
            }

            var numerator   = _operator.Add(_operator.Multiply(_operator.Multiply(3, point.X), point.X), CoefficientA);
            var denominator = _operator.Multiply(2, point.Y);
            var lambda      = _operator.Divide(numerator, denominator);

            var x = _operator.Subtract(_operator.Multiply(lambda, lambda), _operator.Multiply(2, point.X));
            var y = _operator.Subtract(_operator.Multiply(_operator.Subtract(point.X, x), lambda), point.Y);

            return(new EccPoint(x, y));
        }