If we have a representation of $N = ma^2 + nb^2 = mc^2 + nd^2$ in two different ways, we can get its factorization as $(N, ad+bc) \cdot \frac{N}{(N, ad+bc)}$ where $(x,y)$ is the GCD of $x$ and $y$.
How do we do the reverse?
Suppose we have the factorization of $N = pq$. How can we get the two representations of $N$ of the form $N = ma^2 + nb^2 = mc^2 + nd^2$.
What I have so far.
If $N = ma^2 + nb^2 = mc^2 + nd^2$ then
$$ (d^2-b^2)N = m(ad-bc)(ad+bc) $$
If we take $m = d^2 - b^2$ then we can factor $m$ and fix $d, b$.
Also, we have $$ N = (ad - bc)(ad + bc) $$
Taking
$$ ad - bc = p\\ ad + bc = q $$
we get
$$ a = \frac{q+p}{2d} \\ c = \frac{q-p}{2b} $$
This means $p,q$ have same parity and $d|(q+p)$ and $b|(q-p)$ for $a,c$ to be integers. How do we prove that $a,c$ are integers?