Understanding Primitive Polynomials in GF(2)?

This is an entire field over my head right now, but my research into LFSRs has brought me here.

It’s my understanding that a primitive polynomial in $GF(2)$ of degree $n$ indicates which taps will create an LFSR. Such as $x^4+x^3+1$ is primitive in $GF(2)$ and has degree $4$, so a 4 bit LFSR will have taps on bits 4 and 3.

Let’s say I didn’t have tables telling me what taps work for what sizes of LFSRs. What process can I go through to determine that $x^4+x^3+1$ is primitive and also show that $x^4+x^2+x+1$ is not (I made that equation up off the top of my head from what I understand about LFSRs, I think it’s not primitive)?

Several pages online say that you should divide $x^e+1$ (where e is $2^n-1$ and $n$ is the degree of the polynomial) by the polynomial, e.g. for $x^4+x^3+1$, you do $(x^{15}+1)/(x^4+x^3+1)$. I can divide polynomials but I don’t know what the result of that division will tell me? Am I looking for something that divides evenly? Does that mean it’s not primitive?

Solutions Collecting From Web of "Understanding Primitive Polynomials in GF(2)?"

For a polynomial $p(x)$ of degree $n$ with coefficients in $GF(2)$ to be primitive, it must satisfy the condition that $2^n-1$ is the smallest positive integer $e$ with the property that
$$
x^e\equiv 1\pmod{p(x)}.
$$
You got that right.

For a polynomial to be primitive, it is necessary (but not sufficient) for it to be irreducible. Your “random” polynomial
$$
x^4+x^2+x+1=(x+1)(x^3+x^2+1)
$$
fails this lithmus test, so we don’t need to check anything more.

Whenever I am implementing a finite field of characteristic two in a computer program at the beginning I generate a table of discrete logarithms. While doing that I also automatically verify that $2^n-1$ is, indeed, the smallest power of $x$ that yield remainder $=1$. For an in situ example see the latter half of my answer to this question, where I verify that $x^3+x+1$ is primitive by showing that we need to go up to $x^7$ to get remainder equal to $1$.

Doing it by hand becomes tedious after while. There are several shortcuts available, if you know that $p(x)$ is irreducible and if you know the prime factorization of $2^n-1$. These depend on the fact the multiplicative group of $GF(2^n)$ is always cyclic. Your example of $p(x)=x^4+x^3+1$ is a case in point. It is relatively easy to decide that it is
irreducible. Then the theory of cyclic groups tells that the smallest $e$ will be factor of $15$. So to prove that it is actually equal to fifteen it suffices to check that none of
$e=1,3,5$ work. This is easy. The only non-trivial check is that
$$
x^5\equiv x^5+x(x^4+x^3+1)=x^4+x\equiv x^4+x+(x^4+x^3+1)=x^3+x+1\not\equiv1\pmod{x^4+x^3+1},
$$
and this gives us the proof.

Even with the shortcuts, finding a primitive polynomial of a given degree is a task I would rather avoid. So I use look up tables. My favorite on-line source is at

http://web.eecs.utk.edu/~plank/plank/papers/CS-07-593/primitive-polynomial-table.txt

After you have one primitive polynomial, you often want to find other closely related ones. For example, when calculating generating polynomials of a BCH-code or an LFSR of a Gold sequence (or other sequence with known structure) you encounter the following task. The given primitive polynomial is the so called minimal polynomial of any one of its roots, say $\alpha$. Those constructions require you to find the minimal polynomial of $\alpha^d$ for some $d$. For example $d=3$ or $d=5$ are very common. The minimal polynomial of $\alpha^d$ will be primitive, iff $\gcd(d,2^n-1)=1$, and this often holds.
Then relatively basic algebra of field extensions gives you an algorithm for finding the desired minimal polynomial. Space won’t permit me to get into that here, though.

A good (not too theoretical) oveview is Kerl’s “Computation in finite fields” (it is incomplete, sadly). It looks a bit at LFSRs too. BTW, any polynomial defines a LFSR, the point is that primitive polynomials give ones with nice properties.