clear;

x:=10;
q:=x^2+x+1;
t1:=-x;
t2:=x+1;

while not IsPrime(q) or not (IsPrime(q+1-t1) or IsPrime(q+1-t2)) do
	x:=x+1;
	q:=x^2+x+1;
	t1:=-x;
	t2:=x+1;
end while;

Fq:=GF(q);


if IsPrime(q+1-t1) then
	print "t1";
	Factorization(4*q-t1^2);
	nE:=0;
	while nE ne (q+1-t1) do
		E:=EllipticCurve([Fq|Random(Fq),Random(Fq)]);
		nE:=#E;
	end while;
else
	print "t2";
	Factorization(4*q-t2^2);
	nE:=0;
	while nE ne (q+1-t2) do
		E:=EllipticCurve([Fq|Random(Fq),Random(Fq)]);
		nE:=#E;
	end while;
end if;

E;

