Go to the first, previous, next, last section, table of contents.

## Representation of finite fields

On Asir GF(p) and GF(2^n) can be defined, where GF(p) is a finite prime field of charateristic p and GF(2^n) is a finite field of characteristic 2. These are all defined by `setmod_ff()`.

``` P=pari(nextprime,2^50);
1125899906842679
 setmod_ff(P);
1125899906842679
 field_type_ff();
1
 load("fff");
1
 F=defpoly_mod2(50);
x^50+x^4+x^3+x^2+1
 setmod_ff(F);
x^50+x^4+x^3+x^2+1
 field_type_ff();
2
```

If p is a positive integer, `setmod_ff(p)` sets GF(p) as the current base field. If f is a univariate polynomial of degree n, `setmod_ff(f)` sets GF(2^n) as the current base field. GF(2^n) is represented as an algebraic extension of GF(2) with the defining polynomial f mod 2. In both cases the primality check of the argument is not done and the caller is responsible for it.

Correctly speaking there is no actual object corresponding to a 'base field'. Setting a base field means that operations on elements of finite fields are done according to the arithmetics of the base field. Thus, if operands of an arithmetic operation are both rational numbers, then the result is also a rational number. However, if one of the operands is in a finite field, then the other is automatically regarded as in the same finite field and the operation is done in the finite field.

A non zero element of a finite field belongs to the number and has object identifier 1. Its number identifier is 6 if the finite field is GF(p), 7 if it is GF(2^n).

There are several methods to input an element of a finite field. An element of GF(p) can be input by `simp_ff()`.

``` P=pari(nextprime,2^50);
1125899906842679
 setmod_ff(P);
1125899906842679
 A=simp_ff(2^100);
3025
 ntype(@@);
6
```

In the case of GF(2^n) the following methods are available.

``` setmod_ff(x^50+x^4+x^3+x^2+1);
x^50+x^4+x^3+x^2+1
 A=@;
(@)
 ptogf2n(x^50+1);
(@^50+1)
 simp_ff(@@);
(@^4+@^3+@^2)
 ntogf2n(2^10-1);
(@^9+@^8+@^7+@^6+@^5+@^4+@^3+@^2+@+1)
```

Elements of finite fields are numbers and one can apply field arithmetics to them. `@` is a generator of GF(2^n) over GF(2). See section Types of numbers.

Go to the first, previous, next, last section, table of contents.