Esempio n. 1
0
    def change_iso_curve(self, a):
        """
        INPUT:
        * a the montgomery a coefficient of the target curve
        OUTPUT:
        * the point P seen in the new curve
        """
        a1 = self.curve.Fp2(self.curve.a)
        if (a**2 - 4) * (a1**2 - 3)**3 != (a1**2 - 4) * (a**2 - 3)**3:
            # i.e if  256*(a1**2 - 3)**3/(a1**2 - 4) != 256*(a**2 - 3)**3/(a**2 - 4)
            raise RuntimeError('the curves are not isomorphic.')
        E_a1 = EllipticCurve(self.curve.Fp2, [0, a1, 0, 1, 0])
        E_a = EllipticCurve(self.curve.Fp2, [0, a, 0, 1, 0])
        xP = self.x / self.z
        yP = sqrt(xP**3 + a1 * xP**2 + xP)

        P_ws = E_a1(xP, yP)
        iso = E_a1.isomorphism_to(E_a)
        curve_target = copy(self.curve)
        curve_target.a = a
        return Point(iso(P_ws)[0], 1, curve_target)