(self, bytes_arr: bytes)
return TwistedEdwardsCurveElement(x, y)
Decode a bytes objects, expected to be 32 bytes (256 bits) long, into a self-typed object
        Note that this decode is not simply a reverse of the encode above
        :param bytes_arr:
        :return: Output -1 is the result is not in the TEC group, otherwise the correct answer
Decode a bytes objects, expected to be 32 bytes (256 bits) long, into a self-typed object
        Note that this decode is not simply a reverse of the encode above
        :param bytes_arr:
        :return: Output -1 is the result is not in the TEC group, otherwise the correct answer
Decode a bytes objects expected to be 32 bytes ( 256 bits ) long into a self - typed object Note that this decode is not simply a reverse of the encode above : param bytes_arr : : return : Output - 1 is the result is not in the TEC group otherwise the correct answer
def decode(self, bytes_arr: bytes):
        """
        Decode a bytes objects, expected to be 32 bytes (256 bits) long, into a self-typed object
        Note that this decode is not simply a reverse of the encode above
        :param bytes_arr:
        :return: Output -1 is the result is not in the TEC group, otherwise the correct answer
        """
        if len(bytes_arr) % 2 != 0:
            raise ValueError("Cannot decode an odd-long bytes into a TEC element")
        y = IntegersModuloPrimeElement(bytes_to_int(bytes_arr), arithmetic=self.FA)

        # determine x
        denominator = self.FA.sub(self.a, self.FA.mul(self.d, self.FA.pow(y, 2)))   # a - dy^2
        numerator = self.FA.sub(self.FA.get_mul_identity(), self.FA.pow(y, 2))
        x_pos, x_neg = self.FA.sqrt(self.FA.div(numerator, denominator))

        # if the decoded object is invalid, return -1
        if type(x_pos) is int and x_pos == -1:
            return -1

        # if the first byte of the byte_arr is less than half a byte's bit-length,
        #   then use the positive square root as x, otherwise negative
        x = x_pos if bytes_arr[0] < 128 else x_neg
        return TwistedEdwardsCurveElement(x, y)
def decode ( self , bytes_arr : bytes ) : if len ( bytes_arr ) % 2 != 0 : raise ValueError ( "Cannot decode an odd-long bytes into a TEC element" ) y = IntegersModuloPrimeElement ( bytes_to_int ( bytes_arr ) , arithmetic = self . FA ) # determine x denominator = self . FA . sub ( self . a , self . FA . mul ( self . d , self . FA . pow ( y , 2 ) ) ) # a - dy^2 numerator = self . FA . sub ( self . FA . get_mul_identity ( ) , self . FA . pow ( y , 2 ) ) x_pos , x_neg = self . FA . sqrt ( self . FA . div ( numerator , denominator ) ) # if the decoded object is invalid, return -1 if type ( x_pos ) is int and x_pos == - 1 : return - 1 # if the first byte of the byte_arr is less than half a byte's bit-length, #   then use the positive square root as x, otherwise negative x = x_pos if bytes_arr [ 0 ] < 128 else x_neg return TwistedEdwardsCurveElement ( x , y )