0(N)).
The algorithm is described in Steven Galbraith's Oxford Ph.D. thesis.
The implimentation (written in one afternoon) is not efficient, but
it was good enough for the application of determining all trigonal
modular curves, for which it was written.