TITLE: Primes of the form $p=a^2-2b^2$.
QUESTION [10 upvotes]: I've stumbled upon this and I was wondering if anyone here could come up with a simple proof:
Let $p$ be a prime such that $p\equiv 1 \bmod 8$, and let $a,b\geq 1$ such that 
$$p=a^2-2b^2.$$
Question: Is $b$ necessarily a square modulo $p$? 
I have plenty of numerical data to support an affirmative answer, but the proof eludes me so far. For instance:
\begin{align*}
17 & = 5^2 - 2\cdot 2^2\\
&= 7^2 - 2\cdot 4^2\\
& = 23^2 - 2\cdot 16^2\\
& = 37^2 - 2\cdot 26^2\\
& = 133^2 - 2\cdot 94^2\\
\end{align*}
and $2\equiv 36$, $4$, $16$, $26\equiv 9$, $94\equiv 9 \bmod 17$ are squares.
Thanks!

REPLY [12 votes]: Since $p\equiv 1\pmod 8$, $2$ is a square modulo $p$. It will therefore be enough to show that any odd prime divisor of $b$ is also a square modulo $p$. Then any prime divisor of $b$ will be a square modulo $p$, therefore $b$ itself will be.
Let $q$ be an odd prime divisor of $b$, and consider your equation modulo $q$. You find that $p\equiv a^2 \pmod{q}$, so that $p$ is a square modulo $q$. By quadratic reciprocity (using that $p\equiv 1\pmod 4$), $q$ is a square modulo $p$.