To motivate my question, recall the following well-known fact: Suppose that $p\equiv 1\pmod 4$ is a prime number. Then the equation $x^2\equiv -1\pmod p$ has a solution.
One can show this as follows: Consider the following polynomial in ${\mathbb Z}_p[x]$: $x^{4k}-1$, where $p=4k+1$. The roots of this polynomial are precisely the elements of ${\mathbb Z}_p^*$, each one with multiplicity 1. The polynomial factors as $(x^{2k}-1)((x^k)^2+1)$, and it follows that if $a$ is any element of ${\mathbb Z}_p^*$ with $a^{2k}\ne 1$ (and there are precisely $(p-1)/2$ possible such $a$), then $b=a^k$ satisfies $b^2\equiv -1\pmod p$.
Of course, there are other arguments, but I am interested in pursuing this line of reasoning. My question is the following:
From the quadratic reciprocity law, we have that $x^2\equiv -2\pmod p$ has a solution iff $p\equiv 1$ or $3\pmod 8$. Is there a proof of the right-to-left implication using some polynomial and appropriate counting of roots, as in the case shown above?