The question is:
Establish that every prime number p of the form $ 8k + 1$ or $8k +3$ can be written as $ p = a^2 + 2b^2$ for some choice of integers a and b.
And the Hint says:
Mimic the proof of theorem 13.2, which is given below:
My trial is:
For the case: $p = 8k + 1$
I used the theorem that says the Legendre symbol $(2/p) = 1$ if $p \equiv 1 \pmod 8$
And I end up after using Thue lemma that $$2x_{0}^2 \equiv y_{0}^2,$$
But this will lead to $p = 2a^2 - b^2$ which is not the required, could anyone help me in fixing this please?
I feel that I need the Legendre symbol $(2/p) = 1$ if $p \equiv 1 \pmod 8$ to be $(- 2/p) = 1$ if $p \equiv 1 \pmod 8$ instead, but How can I do this ?
What about the second case when $p \equiv 3 \pmod 8$?



Since the Legendre symbol is multiplicative we have: $$\left(\frac{-2}{p}\right)=\left(\frac{2}{p}\right)\left(\frac{-1}{p}\right)$$ The first one is equal to $1$ iff $p \equiv 1,7 \pmod{8}$ and the second iff $p \equiv 1 \pmod{4}$. So they are both one when $p \equiv 1 \pmod{8}$ and both $-1$ when $p \equiv 3 \pmod{8}$. In both cases their product is one which means that $-2$ is a quadratic residue mod $p$ i.e. there exists an integer $a$ such that: $$a^2 \equiv -2 \pmod{p}$$ Now you mimic the given proof and everything should work out well.