TITLE: Prove that $\displaystyle \prod_{1\leq a<b\leq \frac{p-1}{2}}\,\left(a^2+b^2\right)\equiv \pm1\pmod{p}$ for a prime $p\equiv 3\pmod{4}$.
QUESTION [5 upvotes]: Show that, if $p$ is a prime which is congruent to $3\pmod{4}$, then the product $$\prod_{1\le a < b \le \frac{p-1}{2}} (a^{2}+b^{2}) \equiv \pm{1} \pmod{p}\,.$$ 
I verified this for simpler cases but I am not sure how to proceed. For example, if $p=7$, then the product is $$5 \cdot 13 \cdot 10 \equiv -1\pmod{7}\,.$$

REPLY [6 votes]: Let $\mathbb{F}_p\cong\mathbb{Z}/p\mathbb{Z}$ be the field of order $p$.  We shall work in the field $\mathbb{F}_p[\text{i}] \cong \mathbb{F}_p[x]/\left(x^2+1\right)\cong \mathbb{F}_{p^2}$, where $\text{i}:=\sqrt{-1}$.  Write $\mathbb{F}_p^\times$ for the multiplicative group $\mathbb{F}_p\setminus\{0\}$ of $\mathbb{F}_p$.  
First, define $$S:=\left(\prod_{1\leq a<b\leq \frac{p-1}{2}}\,\left(a^2+b^2\right)\right)^2\,\left(\prod_{k=1}^{\frac{p-1}{2}}\,\left(2k^2\right)\right)=\prod_{a=1}^{\frac{p-1}{2}}\,\prod_{b=1}^{\frac{p-1}{2}}\,\left(a^2+b^2\right)\,.$$
Thus,
$$S=\prod_{a=1}^{\frac{p-1}{2}}\,\prod_{b=1}^{\frac{p-1}{2}}\,\left(a+\text{i}b\right)\left(a-\text{i}b\right)=\prod_{a=1}^{\frac{p-1}{2}}\,\prod_{b\in\mathbb{F}_p^\times}\,\left(a-\text{i}b\right)=\prod_{a=1}^{\frac{p-1}{2}}\,\text{i}^{p-1}\,\prod_{b\in\mathbb{F}_p^\times}\,(-\text{i}a-b)\,.$$
Recall that $\displaystyle\prod_{b\in\mathbb{F}_p^\times}\,(x-b)=x^{p-1}-1$.  Therefore,
$$S=\prod_{a=1}^{\frac{p-1}{2}}\,(-1)^{\frac{p-1}{2}}\,\left((-\text{i}a)^{p-1}-1\right)=\prod_{a=1}^{\frac{p-1}{2}}\,(-1)^{\frac{(p-1)}{2}}\left((-1)^{\frac{p-1}{2}}\,a^{p-1}-1\right)\,.$$
Since $p\equiv 3\pmod{4}$, we have
$$S=\prod_{a=1}^{\frac{p-1}{2}}\,\left(a^{p-1}-(-1)^{\frac{p-1}{2}}\right)=\prod_{a=1}^{\frac{p-1}{2}}\,\big(1-(-1)\big)=\prod_{a=1}^{\frac{p-1}{2}}\,2=2^{\frac{p-1}{2}}\,,$$
where Fermat's Little Theorem has been implemented.  Let $\displaystyle M:=\prod_{1\leq a<b\leq \frac{p-1}{2}}\,\left(a^2+b^2\right)$; ergo,
$$2^{\frac{p-1}{2}}=S=M^2\,\prod_{k=1}^{\frac{p-1}{2}}\,\left(2k^2\right)=M^2\,2^{\frac{p-1}{2}}\,\prod_{k=1}^{\frac{p-1}{2}}\,k^2=M^2\,2^{\frac{p-1}{2}}\,(-1)^{\frac{p-1}{2}}\,\prod_{k\in\mathbb{F}_p^\times}\,k\,.$$
Since $\displaystyle\prod_{k\in\mathbb{F}_p^\times}\,k=(p-1)!=-1$ by Wilson's Theorem and $(-1)^{\frac{p-1}{2}}=-1$, we get
$$2^{\frac{p-1}{2}}=M^2\cdot2^{\frac{p-1}{2}}\cdot(-1)\cdot(-1)=2^{\frac{p-1}{2}}\,M^2\text{ or }M^2=1\,.$$  Consequently, $M=\pm 1$, as desired.
P.S. I wonder about the distribution of prime natural numbers $p \equiv 3\pmod{4}$ such that $M\equiv 1\pmod{p}$.  Let me call these primes extraordinary.  So far, I have found no identifiable patterns for extraordinary primes.  There are eight primes congruent to $3$ modulo $4$ that are less than $50$ (namely, $3$, $7$, $11$, $19$, $23$, $31$, $43$, and $47$), and exactly half of them ($3$, $19$, $31$, and $47$) are extraordinary.  Can anybody with knowledge in analytic number theory compute the following limits:
$$\lim_{N\to \infty}\,\frac{\#\big\{p\in\mathbb{P}(3,4)\,\big|\,p\text{ is extraordinary and }p\leq N\big\}} {\#\big\{p\in\mathbb{P}(3,4)\,\big|\,p\leq N\big\}}$$
and
$$\lim_{N\to\infty}\,\frac{\sum\left\{\frac{1}{p}\,\Big|\,p\in\mathbb{P}(3,4)\text{ is extraordinary and }p\leq N\right\}}{\sum\left\{\frac{1}{p}\,\Big|\,p\in\mathbb{P}(3,4)\text{ and }p\leq N\right\}}\,?$$
Here, $\mathbb{P}(k,m)$ is the set of prime natural numbers $p$ such that $p\equiv a\pmod{m}$.  (My guess is that both limits are equal to $\frac{1}{2}$.)