Let us recall an important fact from plane Euclidean geometry. Suppose that $x=(x_1,x_2)$ and $y=(y_1,y_2)$ are non-zero vectors in $\mathbb{R}^2$ such that $$\sqrt{x_1^2+x_2^2}=\sqrt{y_1^2+y_2^2}.$$ Then there exists a unique angle $\theta$ such that $$\begin{pmatrix} \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \end{pmatrix}\begin{pmatrix} x_1 \\ x_2 \end{pmatrix}=\begin{pmatrix} y_1 \\ y_2 \end{pmatrix}.$$
In a slightly fancier language, we are saying the following. Let $x$ and $y$ be as above. Let $SO_2(\mathbb{R})$ denote the group of orthogonal $2$ by $2$ matrices with real entries with determinant $1$. What we are saying is that if $x$ and $y$ are non-zero vectors in the plane such that $|x|=|y|$, where $|\cdot|$ denotes the Euclidean distance, then there exists a unique $g\in SO_2(\mathbb{R})$ such that $gx=y$.
But let's move on to the next example. Let $\mathbb{Z}_p^2$ be a $2$-dimensional vector space over finite field $\mathbb{Z}_p$. Consider the "distance" on $\mathbb{Z}_p^2$: if $x=(x_1,x_2)\in \mathbb{Z}_p^2$ then $\lVert x\rVert:=x_1^2+x_2^2$.
Lemma: Let $x$ and $y$ be a non-zero vectors in $\mathbb{Z}_p^2$, $p$ prime congruent to $3$ modulo $4$. Suppose that $$\lVert x\rVert:=x_1^2+x_2^2=y_1^2+y_2^2=:\lVert y\rVert.$$ Then there exists a unique $g\in SO_2(\mathbb{Z}_p)$ such that $$gx=y.$$
My approach: I know how to prove the case when are dealing with $\mathbb{R}^2$ but I have some issues with finite field setting. I was trying to do in this way: Suppose $x_1^2+x_2^2=y_1^2+y_2^2=t$, where $t\in \mathbb{Z_p}$. I was able to show that $t\neq 0$ because $-1$ is not square in $\mathbb{Z}_p$, if $p\equiv 3 \pmod 4$. Then I stuck.
Questions:
Can anyone show the proof of this lemma, please? I suppose it should not be difficult. I would prefer the simple via direct calculation.
What happenes if $p$ is not constrained to be congruent to $3$ modulo $4$?
The element of $SO_2$ such that $g\begin{pmatrix} x_1 \\ x_2 \end{pmatrix}=\begin{pmatrix} y_1 \\ y_2 \end{pmatrix}$ is $$g=\pmatrix{y_1&-y_2\\y_2&y_1}\pmatrix{x_1&-x_2\\x_2&x_1}^{-1} $$
It is unique because there is a unique element of $SO_2$ such that $h\pmatrix{1\\0}=\pmatrix{1\\0}$.
The condition $p\equiv 3\bmod 4$ is needed only to say that $x_1^2+x_2^2\ne 0$ ie. $\pmatrix{x_1&-x_2\\x_2&x_1}$ is inversible.