galois.is_primitive

galois.is_primitive(poly)

Determines whether the polynomial \(f(x)\) over \(\mathrm{GF}(q)\) is primitive.

A degree-\(m\) polynomial \(f(x)\) over \(\mathrm{GF}(q)\) is primitive if it is irreducible and \(f(x)\ |\ (x^k - 1)\) for \(k = q^m - 1\) and no \(k\) less than \(q^m - 1\).

Parameters

poly (galois.Poly) – A degree-\(m\) polynomial \(f(x)\) over \(\mathrm{GF}(q)\).

Returns

True if the polynomial is primitive.

Return type

bool

References

Examples

All Conway polynomials are primitive.

In [1]: f = galois.conway_poly(2, 8); f
Out[1]: Poly(x^8 + x^4 + x^3 + x^2 + 1, GF(2))

In [2]: galois.is_primitive(f)
Out[2]: True

In [3]: f = galois.conway_poly(3, 5); f
Out[3]: Poly(x^5 + 2x + 1, GF(3))

In [4]: galois.is_primitive(f)
Out[4]: True

The irreducible polynomial of \(\mathrm{GF}(2^8)\) for AES is not primitive.

In [5]: f = galois.Poly.Degrees([8,4,3,1,0]); f
Out[5]: Poly(x^8 + x^4 + x^3 + x + 1, GF(2))

In [6]: galois.is_primitive(f)
Out[6]: False