CoCalc Public Filestate.sagews
Views : 48
Description: Using the tate pairing from PARI.
Compute Environment: Ubuntu 18.04 (Deprecated)
gp.read(get_remote_file('http://math.stanford.edu/~stange/scripts/tate_via_nets.gp'))

Attempting to load remote file: http://math.stanford.edu/~stange/scripts/tate_via_nets.gp Loading: [.]
%gp
tate_pairing_alg

(elliptic_curve,point_a,point_b,torsion)->local(V,initial_data,x1,y1,x2,y2,a4,a6,resultV);V=matrix(2,8);initial_data=vector(4);if(ellisoncurve(elliptic_curve,point_a)==0,print("The first point is not on the curve!"););if(ellisoncurve(elliptic_curve,point_b)==0,print("The second point is not on the curve!"););if(elliptic_curve[1]!=0||elliptic_curve[2]!=0||elliptic_curve[3]!=0,print("Curve not in two-coeff. Weierstrass form!");a1=elliptic_curve[1];a2=elliptic_curve[3];a3=elliptic_curve[2];a4=elliptic_curve[4];a6=elliptic_curve[5];coordinate_change=[1/6,-a2/3,-a1/2,-a3/2+a1*a2/6];elliptic_curve=ellchangecurve(elliptic_curve,coordinate_change);point_a=ellchangepoint(point_a,coordinate_change);point_b=ellchangepoint(point_b,coordinate_change);print("New curve: ",elliptic_curve);print("New first point: ",point_a);print("New second point: ",point_b););x1=point_a[1];y1=point_a[2];x2=point_b[1];y2=point_b[2];a4=elliptic_curve[4];a6=elliptic_curve[5];V[1,4]=1;V[1,5]=2*y1;V[1,6]=3*x1^4+6*a4*x1^2+12*a6*x1-a4^2;V[1,7]=4*y1*(x1^6+5*a4*x1^4+20*a6*x1^3-5*a4^2*x1^2-4*a4*a6*x1-8*a6^2-a4^3);V[1,8]=-((V[1,6])^3-(V[1,5])^3*(V[1,7]));V[1,3]=0;V[1,2]=-V[1,4];V[1,1]=-V[1,5];V[2,1]=1;V[2,2]=1;V[2,3]=2*x1+x2-((y2-y1)/(x2-x1))^2;if(debug==1,print("The beginning block is: ",V););initial_data[1]=1/(V[1,5]);initial_data[2]=1;initial_data[3]=1/(x1-x2);initial_data[4]=1/((y1+y2)^2-(2*x1+x2)*(x1-x2)^2);if(debug==1,print("Precomputed inverses: ",initial_data););resultV=net_loop(V,initial_data,torsion);return(resultV[2,3]/resultV[1,5])