Path: blob/main/dead-code/FromJacToJac.sage
323 views
def FromJacToJac(h, D11, D12, D21, D22, a):1R.<x> = h.parent()2Fp2 = R.base()34J = Jacobian(HyperellipticCurve(h))5D1 = J(D11, D12)6D2 = J(D21, D22)78G1 = (2^(a-1)*D1)[0]9G2 = (2^(a-1)*D2)[0]10G3 = h / (G1*G2)1112delta = Matrix(Fp2, 3, 3, [Coefficient(G1, 0), Coefficient(G1, 1), Coefficient(G1, 2),13Coefficient(G2, 0), Coefficient(G2, 1), Coefficient(G2, 2),14Coefficient(G3, 0), Coefficient(G3, 1), Coefficient(G3, 2)])15delta = delta.determinant()^(-1)1617H1 = delta*(derivative(G2)*G3 - G2*derivative(G3))18H2 = delta*(derivative(G3)*G1 - G3*derivative(G1))19H3 = delta*(derivative(G1)*G2 - G1*derivative(G2))2021hnew = H1*H2*H322Jnew = Jacobian(HyperellipticCurve(hnew))2324# now compute image points25# first the point [D11, D12]:2627u0 = Coefficient(D11, 0)28u1 = Coefficient(D11, 1)29v0 = Coefficient(D12, 0)30v1 = Coefficient(D12, 1)31S.<x1,y1,y2,x2> = PolynomialRing(Fp2, 4)32# TODO: How is this computed in sage?33# pr = hom<S -> R | 0, 0, 0, x>3435eq1 = x1^2 + u1*x1 + u036eq2 = v1*x1 + v0 - y137# TODO: What is evaluate doing?38# eq3 = Evaluate(G1, x1)*Evaluate(H1, x2) + Evaluate(G2, x1)*Evaluate(H2, x2)39# eq4 = y1*y2 - Evaluate(G1, x1)*Evaluate(H1, x2)*(x1 - x2)40# eq5 = y1^2 - Evaluate(h, x1)4142I = Ideal([eq1, eq2, eq3, eq4, eq5])43G = GroebnerBasis(I) # last two are in non-reduced Mumford form: y2 + cubic(x2), quartic(x2)44# TODO what is pr?45# unew = pr(G[len(G)])46# vnew = -pr(G[len(G)-1])47# sanity check: (vnew^2 - hnew) mod unew48# TODO what is pr?49# imD1 = Jnew(pr(G[len(G)]), -pr(G[len(G)-1]))5051# now same for the point [D21, D22]:5253u0 = Coefficient(D21, 0)54u1 = Coefficient(D21, 1)55v0 = Coefficient(D22, 0)56v1 = Coefficient(D22, 1)57eq1 = x1^2 + u1*x1 + u058eq2 = v1*x1 + v0 - y159I = Ideal([eq1, eq2, eq3, eq4, eq5])60G = GroebnerBasis(I)61# TODO what is pr?62# unew = pr(G[len(G)])63# vnew = -pr(G[len(G)-1])64# TODO what is pr?65# imD2 = Jnew(pr(G[len(G)]), -pr(G[len(G)-1]))6667return hnew, imD1[0], imD1[1], imD2[0], imD2[1]6869