TITLE: A particular case of the quadratic reciprocity law
QUESTION [15 upvotes]: 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?

REPLY [6 votes]: If I remember correctly, this approach with a Gauss sum (associated to an 8th root of 1 in a finite field) is used in the first page or two of Serre's Cours d'Arithmetique to determine the "supplementary law" for $\left( \frac{2}{p} \right)$.  The magical algebraic identity in this case is that if $a^4 = -1$, then $(a \pm 1/a)^2 = \pm 2$.