How to prove that if $a^x \equiv a^y \pmod n$ then $x \equiv y \pmod{\operatorname{ord}_{n}(a)}$? I can easily prove the inverse, however I cannot prove this.
We know that $\operatorname{ord}_{n}(a)\mid\phi(n)$, so I have been trying to prove that $x \equiv y \pmod{\phi(n)}$ and it follows that $x \equiv y \pmod{\operatorname{ord}_{n}(a)}$.
I have also noted some relevant properties that might be of help:
$$a^{\operatorname{ord}_{n}(a)}\equiv 1 \pmod n $$
$$\gcd(a,n)=1$$
$$\operatorname{ord}_{n}(a)\mid\phi(n)$$
$$a^{\phi(n)} \equiv 1\pmod n$$
If $\gcd(a,n)=1$ then $a$ is invertible modulo $n$, so we actually have (multiplying by $(a^{-1})^y$) that $a^{x-y}\equiv 1 \mod n$. Now it is clear that $x-y\equiv 0 \mod \text{ord}_n(a)$.
You only need to use the definition of the order of $a$ modulo $n$:
It is the least positive integer $k$ such that $a^k\equiv 1\pmod n$. The set of such integers is an ideal in $\mathbf Z$, and  $\operatorname{ord}_n(a)$ is the positive generator of this ideal.
Now, $a^x\equiv a^y\mod n\iff a^{x-y}\equiv 1\mod n$, which means  $\operatorname{ord}_n(a)\mid x-y$ .