This is the first time I'm posting a question, so I apologize beforehand if I have made any mistake. I'm trying to prove the following argument but couldn't finish ($\implies$) part. Also, I came up with a solution for ($\impliedby$) but still not sure.
Theorem: Let $p$ be an odd prime. Show that $p$ is not an irreducible element of $\mathbb{Z}[i]$ $\iff$ there exists an integer $x$ such that $x^2\equiv -1$ (mod $p$).
My attempt:
($\implies$) If $p$ is not irreducible in $\mathbb{Z}[i]$ (and $p$ is not zero nor a unit), it can be expressed as product of two non-unit elements, say $p=(a+bi)(c+di)$ for some $a,b,c,d\in \mathbb{Z}$, so $p^2=N(a+bi)N(c+di)$ but $N(a+bi)>1$ and $N(c+di)>1$ since they are not units. Then $p.p=p^2=(a^2+b^2)(c^2+d^2)$ is possible only if $p=a^2+b^2=c^2+d^2$. Observe $p\equiv 3$ (mod 4) or $p\equiv 1$ (mod $4$). First one isn't possible since $a^2+b^2\equiv 0,1$, or $2$ (mod $4$). So, we conclude $p\equiv 1$ (mod $4$)......
I don't know how to proceed from now on (though I know Legendre's symbol and using Euler's criterion I can prove the existence of such $x$, this course is about Rings & Fields and I am trying to prove the existence of $x$ for $p\equiv 1$ (mod $4$) using ring theory)
($\impliedby$) Suppose there is an $x\in\mathbb{Z}$: $x^2\equiv -1$ (mod $p$) and assume for a contradiction that $p$ is irreducible in $\mathbb{Z}[i]$. Then $x^2+1=p.t$ for some $t\in\mathbb{Z}$, ie $x^2+1^2=(x+i)(x-i)=p.t$. Since $\mathbb{Z}[i]$ is a principal ideal domain, any irreducible is also a prime. Thus, $p|(x+i)(x-i)\implies p|(x+i)$ or $p|(x-i)$. If $p|(x+i)$, then $p(k+mi)=(x+i)$ for some $k,m\in\mathbb{Z} \implies p.m=1$ which is not possible. (We reach a similar contradiction for $(x-i)$ case). Thus $p$ cannot be irreducible.