<s>[INST] Prove that $x^2 \equiv y^2 \pmod p$ if and only if $x \equiv y \pmod p$ or $x \equiv -y \pmod p$. Hint: $x^2-y^2 = (x+y)(x-y)$. This is the exercise verbatim:
An integer n is a square modulo p if there exists another integer x
such that $n \equiv x^2 \pmod p$. Prove that $x^2 \equiv y^2 \pmod p$ if and only if $x \equiv y \pmod p$ or $x \equiv  -y \pmod p$.
Hint: $x^2-y^2 = (x+y)(x-y)$.
This is my attempt to solve it:
If $x \equiv y \pmod p$ then $\displaystyle \frac{x-y}{p} = q_1 \Rightarrow (x-y)=pq_1$.
If $x \equiv -y$ then $\displaystyle \frac {x+y}{p}=q_2 \Rightarrow (x +y)=pq_2$.
Then $x^2-y^2 = (x+y)(x-y)=(q_1p)\cdot(q_2p)=q_1q_2p^2$
If $p$ is to divide $ x^2-y^2 $ evenly, then it must also divide $q_1q_2p^2$, therefore $\displaystyle \frac {x^2-y^2}{p}=q_1q_2p$.
To satisfy the condition of divisibility by $p$, $q_1q_2p$ must be an integer. Since the assertion to be proven is "Prove that $x^2 \equiv y^2 \pmod p$ if and only if $x \equiv y \pmod p$ or $x \equiv  -y \pmod p$.", we must show that the premise is true if either $q_1$ or $q_2$ is an integer for sure.
Is this line of reasoning correct up until this point?
How to guarantee that $q_1q_2p$ is an integer?  
 [/INST] Well, use your hint:
$$x^2 - y^2 \equiv 0 \pmod p$$
$$(x+y)(x-y) \equiv 0 \pmod p$$
Clearly, ths is satisfied if $x=y$ or $x=-y$. Because $\mathbb{Z}_p$ has no zero divisors, these are the only solutions.
</s>