Result from $X^2+Y^2=p^{n-1}$ with $p^{n-1} \equiv 1 \pmod{8}$ I'm reading an article and they have the equation $X^2+Y^2=p^{n-1}$ where $p$ is a prime and $p^{n-1} \equiv 1 \pmod{8}$ and $p \equiv 1 \pmod{4}$.
They conclude that since $p^{n-1} \equiv 1 \pmod{8}$ it must follow that 
$$\begin{cases}
 X \equiv 0 \pmod{4} \\ Y \equiv \pm 1 \pmod{4}
 \end{cases}
 \textrm{ or }
\begin{cases}
 X \equiv \pm 1 \pmod{4} \\ Y \equiv 0 \pmod{4}
 \end{cases}.$$
Where does this come from?

Note $p^{n-1} \equiv 1 \pmod 8$ means both sides of $X^2 + Y^2 = p^{n-1}$ is odd. Thus, one of $X$ and one of $Y$ must be even and the other odd. Consider $X$ to be even and $Y$ to be odd. As $Y$ is odd (so $Y \equiv \pm 1 \pmod 4$), when squared, it's $Y^2 \equiv 1 \pmod 8$. With $X$ being even, if it's $X \equiv 2 \pmod 8$, then it's square is $X^2 \equiv 4 \pmod 8$, so $X^2 + Y^2 \equiv 5 \pmod 8$. However, since $X^2 + Y^2 \equiv 1 \pmod 8$, this means $X \equiv 0 \pmod 4$.
The two sets of congruences you ask about just list this for $X$ and $Y$ as I describe above, and since the equation is symmetric in $X$ and $Y$, it also lists the  possibilities for the conditions on $X$ and $Y$ to be switched around.
