$\begingroup$

Let $n$ be an odd number, $D=a^2+4$ and $(D | n)=-1$ where $(D | n)$ is the Jacobi symbol.

Then $n$ is prime if and only if

$(x^2 + ax)^n = x^3 - x^2 + (D-2)x - D \pmod {{x^4 + Dx^2 + D},n}$

or

$(x^2 - ax)^n = x^3 - x^2 + (D-2)x - D \pmod {{x^4 + Dx^2 + D},n}$

I have constructed a proof (here) for the converse of this test but not the actual test itself. Are there counterexamples? A heuristic argument suggesting a counterexample?

There are no counterexamples for any $(|a|,n) < 10000$.

The idea for this algorithm came from a version of Agrawal's Conjecture with $r=5$ involving a quartic polynomial, without resorting to higher-degree polynomials (larger values of $r$). It is much easier to use a constructed family of cyclic quartic polynomials with one free parameter.

You can run the test here;

Also related is this conjecture/test here (which also gave me an idea for this test).