Why does the characterization of Gaussian primes really work? Citing https://en.wikipedia.org/wiki/Gaussian_integer :

A Gaussian integer $a + bi$ is a Gaussian prime if and only if either:

*

*one of $a, b$ is zero and absolute value of the other is a prime number of the form $4n + 3$ (with $n$ a nonnegative integer)

*or both are nonzero and $a^2 + b^2$ is a prime number (which will not be of the form $4n + 3$).


This statement implies the following:

*

*If $a^2 + b^2$ is not prime ($a,b \ne 0$), then there are 2 complex numbers $a_1 + b_1i$ and $a_2 + b_2i$, such that:
$$
a_1^2 + b_1^2 \ne 1
$$
$$
a_2^2 + b_2^2 \ne 1
$$
$$
a + bi = (a_1 + b_1i)(a_2 + b_2i) =>
Magnitude(a + bi) = Magnitude(a_1 + b_1i) Magnitude(a_2 + b_2i) => \sqrt{(a^2 + b^2)} = \sqrt{(a_1^2 + b_1^2)}\sqrt{(a_2^2 + b_2^2)} => (a^2 + b^2) = (a_1^2 + b_1^2)(a_2^2 + b_2^2)
$$

*If $p$ is a prime of the form $4n + 1, n > 0$, then there are 4 integers $a_1, b_1, a_2, b_2$, such that $p^2 = (a_1^2 + b_1^2)(a_2^2 + b_2^2)$
How do we prove these two statements?
EDIT 1
I must misunderstand something. For example, let us take $45 = 3^2 + 6^2$, but I do not think $45$ can be broken as a product of sum of squares. What am I missing?
EDIT 2
As people commented:

*

*$45 = (1^2 + 2^2)(0^2 + 3^2)$

*If $p$ is a prime, such that $p = 4n + 1$ for some $n > 0$, then there integers $u,v$ such that $p = u^2 + v^2$, which trivially resolves the second item in my question. But then, how do we prove that any prime of this form is a sum of squares?

 A: Both of these statements can be deduced from the unique factorization theorem for Gaussian integers, which can in turn be deduced from the fact that $\mathbb{Z}[i]$ is a Euclidean domain (see https://en.wikipedia.org/wiki/Gaussian_integer#Euclidean_division for instance).
To prove the first statement, suppose $a,b\in\mathbb{Z}\setminus\{0\}$ and $a^2+b^2$ is not prime in $\mathbb{Z}$.  If $a+bi$ were a Gaussian prime, then $a-bi$ would also be a Gaussian prime (since complex conjugation is an automorphism of $\mathbb{Z}[i]$), and so $$a^2+b^2=(a+bi)(a-bi)$$ would be the unique (up to units and reordering) prime factorization of $a^2+b^2$ in $\mathbb{Z}[i]$.  In particular, up to units, the only factors of $a^2+b^2$ in $\mathbb{Z}[i]$ are $1,a\pm bi,$ and $a^2+b^2$  But since $a^2+b^2$ is not prime in $\mathbb{Z}$, it has a nontrivial integer factor $c$.  This is a contradiction, since $c$ cannot be associate to any of $1,a\pm bi,$ or $a^2+b^2$.  (Note that we use the assumption that $a,b\neq 0$ to conclude that $c$ cannot be associate to $a\pm bi$.)
To prove the second statement, suppose $p$ is prime in $\mathbb{Z}$ and has the form $4n+1$.  Then $-1$ is a square mod $p$ (since group of units mod $p$ is cyclic of order $4n$ and thus has an element of order $4$), so there is some $a\in\mathbb{Z}$ such that $a^2+1$ is divisible by $p$.  Over $\mathbb{Z}[i]$, we can factor $a^2+1=(a+i)(a-i)$.  If $p$ were prime in $\mathbb{Z}[i]$, then $p$ would have to divide either $a+i$ or $a-i$.  But this is impossible, since then $p$ would divide the imaginary part $\pm 1$.
(Note that it actually follows that $p$ itself is a sum of squares.  Indeed, if $p=(a_1+b_1i)(a_2+b_2i)$ is a nontrivial factorization, then $p^2=(a_1^2+b_1^2)(a_2^2+b_2^2)$ and the only possibility for these factors is $a_1^2+b_1^2=a_2^2+b_2^2=p$ since $p$ is prime.)
