(self, a, b)
return TwistedEdwardsCurveElement(x3, y3)
(x1, y1) + (x2, y2) = ((x1y2 + y1x2) / (1 + dx1x2y1y2), (y1y2 - ax1x2) / (1 - dx1x2y1y2))
        :param a: TwistedEdwardsCurveElement
        :param b: TwistedEdwardsCurveElement
        :return:
(x1, y1) + (x2, y2) = ((x1y2 + y1x2) / (1 + dx1x2y1y2), (y1y2 - ax1x2) / (1 - dx1x2y1y2))
        :param a: TwistedEdwardsCurveElement
        :param b: TwistedEdwardsCurveElement
        :return:
( x1 y1 ) + ( x2 y2 ) = (( x1y2 + y1x2 ) / ( 1 + dx1x2y1y2 ) ( y1y2 - ax1x2 ) / ( 1 - dx1x2y1y2 )) : param a : TwistedEdwardsCurveElement : param b : TwistedEdwardsCurveElement : return :
def add(self, a, b):
        """
        (x1, y1) + (x2, y2) = ((x1y2 + y1x2) / (1 + dx1x2y1y2), (y1y2 - ax1x2) / (1 - dx1x2y1y2))
        :param a: TwistedEdwardsCurveElement
        :param b: TwistedEdwardsCurveElement
        :return:
        """
        if type(a) != TwistedEdwardsCurveElement or type(b) != TwistedEdwardsCurveElement:
            raise TypeError("Addition only supports two objects")
        x1 = a.x
        y1 = a.y
        x2 = b.x
        y2 = b.y

        # calculate essential components
        x1y2 = self.FA.mul(x1, y2)
        x2y1 = self.FA.mul(x2, y1)
        ax1x2 = self.FA.mul(self.a, self.FA.mul(x1, x2))
        y1y2 = self.FA.mul(y1, y2)
        dx1x2y1y2 = self.FA.mul(self.d, self.FA.mul(x1y2, x2y1))

        # calculate the first coordinate
        numerator_x3 = self.FA.add(x1y2, x2y1)
        denominator_x3 = self.FA.add(self.FA.get_mul_identity(), dx1x2y1y2)
        x3 = self.FA.div(numerator_x3, denominator_x3)

        # calculate the second coordinate
        numerator_y3 = self.FA.sub(y1y2, ax1x2)
        denominator_y3 = self.FA.sub(self.FA.get_mul_identity(), dx1x2y1y2)
        y3 = self.FA.div(numerator_y3, denominator_y3)

        return TwistedEdwardsCurveElement(x3, y3)
def add ( self , a , b ) : if type ( a ) != TwistedEdwardsCurveElement or type ( b ) != TwistedEdwardsCurveElement : raise TypeError ( "Addition only supports two objects" ) x1 = a . x y1 = a . y x2 = b . x y2 = b . y # calculate essential components x1y2 = self . FA . mul ( x1 , y2 ) x2y1 = self . FA . mul ( x2 , y1 ) ax1x2 = self . FA . mul ( self . a , self . FA . mul ( x1 , x2 ) ) y1y2 = self . FA . mul ( y1 , y2 ) dx1x2y1y2 = self . FA . mul ( self . d , self . FA . mul ( x1y2 , x2y1 ) ) # calculate the first coordinate numerator_x3 = self . FA . add ( x1y2 , x2y1 ) denominator_x3 = self . FA . add ( self . FA . get_mul_identity ( ) , dx1x2y1y2 ) x3 = self . FA . div ( numerator_x3 , denominator_x3 ) # calculate the second coordinate numerator_y3 = self . FA . sub ( y1y2 , ax1x2 ) denominator_y3 = self . FA . sub ( self . FA . get_mul_identity ( ) , dx1x2y1y2 ) y3 = self . FA . div ( numerator_y3 , denominator_y3 ) return TwistedEdwardsCurveElement ( x3 , y3 )