clear;
q:=59;
Fq:=GF(q);
a:=1; b:=0;
E:=EllipticCurve([Fq|a,b]);
IsSupersingular(E);
r:=5;
Fq2<i>:=ExtensionField<Fq,x|x^2+1>;
#E(Fq2);

points:=Points(E(Fq2));

TorsPts:={};

for i:=1 to #points do
	if r*points[i] eq Identity(E) then
		Include(~TorsPts,points[i]);
	end if;
end for;

function FlowerGenerator(TorsPts);
	V:={};
	S:=TorsPts;
	petals:=Integers()!Sqrt(#S)+1;
	ptsInPet:=petals-1;
	T:={};

	for i:=1 to petals do
		S:=S diff V;
  		P:=Random(S);
	        while P[3] eq 0 do
			P:=Random(S);
  		end while;
	V:={j*P:j in [1..ptsInPet]};
 	Include(~T,V);
	end for;
return T;
end function;

FlowerGenerator(TorsPts);

Dis:= function(P);
	return E(Fq2)![-P[1],i*P[2]];
end function;

P:=E(Fq2)![31*i+51,34*i+49];
Dis(P);

