Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The following code initializes a finite field $\Bbb F_p(j)$, for the prime $p= 2^{127}-1$, so that $j$ satisfies $j^2=-1$.

p = 2**127-1
F = GF(p)
R.<x> = PolynomialRing(F)
K.<j> = GF( p^2, modulus=x^2+1 )

The code is rather simple, but there are many tacitly done constructive details. Let us go step by step. After we define $p$, a prime, we initialize the field $F=\Bbb F_p$ woith $p$ elements. There is no need to specifiy any generator for this finite field, it is a standard construction, no chance for a choice.

Then we define the polynomial ring over $F$. This works also via F[] when we are in big hurry, but here i used the full name for the constructor. The polynomial ring over $F$ needs a transcendental generator, a name for it, so we give one, above it is x. In the next line, we want to introduce a field isomorphic to $\Bbb F_{p^2}$. Again, we need some care to name the generator, and we even want to prescribe it, its minimal polynomial, in sage terminology - its modulus. This is done using the variable x with the "right parent".

Sometimes, all details can be collected in a dialog with the interpreter. Here, i try to address aspects from the posted questions.

sage: p.is_prime()
True
sage: F
Finite Field of size 170141183460469231731687303715884105727
sage: R
Univariate Polynomial Ring in x over Finite Field of size 170141183460469231731687303715884105727 (using NTL)
sage: x
x
sage: x.parent()
Univariate Polynomial Ring in x over Finite Field of size 170141183460469231731687303715884105727 (using NTL)
sage: x == R.gens()[0]
True
sage: K
Finite Field in j of size 170141183460469231731687303715884105727^2
sage: K.modulus()
x^2 + 1
sage: K.modulus() == x^2+1
True
sage: j.minpoly()
x^2 + 1
sage: j^2
170141183460469231731687303715884105726
sage: K.order() == p^2
True

I always avoid "constructors" that do not have "names". For instance, yes, R.<x> = F[] is also a possible way to instantiate the polynoial ring over F, but the "correct", documented way is by using PolynomialRing. Moreovver, ?PolynomialRing gives documentation and examples for the class, for its constructor.

And also, i was avoiding i all the time.