Testing latest pari + WASM + node.js... and it works?! Wow.
License: GPL3
ubuntu2004
Function: ffgen
Section: number_theoretical
C-Name: ffgen
Prototype: GDn
Help: ffgen(k,{v = 'x}): return a generator of the finite field k
(not necessarily a generator of its multiplicative group) as a t_FFELT.
k can be given by its order q, the pair [p,f] with q=p^f, by an irreducible
polynomial with t_INTMOD coefficients, or by a finite field element.
If v is given, the variable name is used to display g, else the variable of
the polynomial or finite field element, or x if only the order was given.
Doc: return a generator for the finite field $k$ as a \typ{FFELT}.
The field $k$ can be given by
\item its order $q$
\item the pair $[p,f]$ where $q=p^f$
\item a monic irreducible polynomial with \typ{INTMOD} coefficients modulo a
prime.
\item a \typ{FFELT} belonging to $k$.
If \kbd{v} is given, the variable name is used to display $g$, else the
variable of the polynomial or the \typ{FFELT} is used, else $x$ is used.
When only the order is specified, the function uses the polynomial generated
by \kbd{ffinit} and is deterministic: two calls to the function with the
same parameters will always give the same generator.
For efficiency, the characteristic is not checked to be prime; similarly
if a polynomial is given, we do not check whether it is irreducible.
To obtain a multiplicative generator, call \kbd{ffprimroot} on the result.
\bprog
? g = ffgen(16, 't);
? g.mod \\ recover the underlying polynomial.
%2 = t^4+t^3+t^2+t+1
? g.pol \\ lift g as a t_POL
%3 = t
? g.p \\ recover the characteristic
%4 = 2
? fforder(g) \\ g is not a multiplicative generator
%5 = 5
? a = ffprimroot(g) \\ recover a multiplicative generator
%6 = t^3+t^2+t
? fforder(a)
%7 = 15
@eprog
Variant:
To create a generator for a prime finite field, the function
\fun{GEN}{p_to_GEN}{GEN p, long v} returns \kbd{ffgen(p,v)\^{}0}.