Let $x,y,e,$ $p$, and $q$ be any integers where $N= pq$ and $e$ is coprime to $(p-1)(q-1)$ . I am wondering whether $x^e \equiv y^e \pmod N $ implies $x \equiv y \pmod N$, and if so how to show this. My first thoughts were to use Fermat's little thrm, but $N$ is not necessarily prime here.
The reason why I am asking is because in RSA cryptosystem, I have learned that a potential strategy for an eavesdropper to figure out the message $x$ given the quantities $N$,$x^e$, and $e$, is to try all possible values $y$, and if $y^e \equiv x^e \pmod N$, then the eavesdropper as found $x$ in the form of $y$. I am trying to justify why the eavesdropper has actually found $x$ here, which depends on the claim I have asked about.
I notice that you are confused with the case where $x$ and/or $y$ may be not coprime to $N$.
The Euler’s theorem states that:
For the case when $m = N = p q$ where $p, q$ are different primes, a generalization holds: For arbitrary $a$ (not necessarily coprime to $N$), $$ a^{\varphi(N) + 1} \equiv a \pmod{N}. $$
For example, when $N = 3 \cdot 5 = 15$, we have the powers of $3$ are $[1, 3, 9, 12, 6, 3, 9, 12, 6, 3, \ldots]$. We find that the $9$-th power is equal to $3$, where $9 = \varphi(15) + 1 = 8 + 1$.
This generalization actually tells us that we can reduce $a^k$ to $a^{k - \varphi(N)}$ as long as $k > \varphi(N)$.
Now consider when $x^e \equiv y^e \pmod{N}$.
We have such $d$ exists as the multiplicative inverse of $e$ modulo $\varphi(N)$, that is, $d e \equiv 1 \pmod{\varphi(N)}$, or equivalently, $d e = k \cdot \varphi(N) + 1$ for some non-negative integer $k$.
Raise the equality to $d$-th power:
$$ \begin{aligned} x^{d e} &\equiv y^{d e} \\ x^{k \varphi(N) + 1} &\equiv y^{k \varphi(N) + 1} \\ x^{(k - 1) \varphi(N) + 1} &\equiv y^{(k - 1) \varphi(N) + 1} \\ \vdots \\ x^{1} &\equiv y^{1} \pmod{N} \end{aligned} $$
And that’s it.