Confusion in proof that primes $p = 4k + 1$ are uniquely the sums of two squares I'm reading a proof in my number theory textbook that all primes of the form $p = 4k+1$ are uniquely the sum of two squares. I'm stuck right at the beginning of the proof, where they say:
To establish the assertion, suppose that
$$
p = a^2 + b^2 = c^2 + d^2
$$
where $a,b,c,d$ are all positive integers. Then
$$
a^2 d^2 - b^2 c^2 = p(d^2 - b^2).
$$
Perhaps I'm just missing something obvious, but I can't figure out how they managed to conclude that $a^2 d^2 - b^2 c^2 = p(d^2 - b^2).$ Please advise.

Have you studied Gaussian integers at all in the years since you asked this question, or prior to that? (I'm here because of a duplicate).
It might help. For example, suppose $$29 = (2 - 5i)(2 + 5i) = 2^2 + 5^2 = c^2 + d^2,$$ where $c \neq 2$ and $d \neq 5$. Then $$2^2 d^2 - 5^2 c^2 = 29(d^2 - 5^2).$$ If we set $d = 0$, then we have $$-5^2 c^2 = -725$$ and so $c = \pm\sqrt{29}$, both of which are outside the domain of Gaussian integers. $d = 1$ also leads to a dead end. Now try $d = 2$, giving us $$16 - 5^2 c^2 = -609.$$ Subtracting 16 from both sides, we have $$-5^2 c^2 = -625.$$ Solving for $c$ we get $c = 5$, which does satisfy the stipulation that $c \neq 2$.
So, all we've done is switch $a$ and $b$ around. Similar results can be obtained by multiplying by $i$ or $-i$.
