To show $|(\mathbb{Z}/n\mathbb{Z})^{\times}| = \varphi(n)$ I know this question has been asked before, but this is (hopefully) not a duplicate. Dummit and Foote's Algebra asks us to show $$|(\mathbb{Z}/n\mathbb{Z})^{\times}| = \varphi(n)$$
using the following definitions, and nothing else:

$(\mathbb{Z}/n\mathbb{Z})^{\times} := \{\bar a \in \mathbb{Z}/n\mathbb{Z} : \exists \bar c \in \mathbb{Z}/n\mathbb{Z}, \bar a \bar c = \bar 1\}$

Here, $\bar a$ denotes the equivalence class of $a$ in $\mathbb{Z}/n\mathbb{Z}$, namely one of $\bar 0,\bar 1,...,\overline{n-1}$. $\bar a\bar c$ refers to the usual multiplication, i.e. we take any elements from the equivalence classes of $\bar a$ and $\bar c$, multiply them, and then reduce the result $\bmod n$. We have shown this works in an earlier proposition, i.e. modular multiplication is well-defined. So, $(\mathbb{Z}/n\mathbb{Z})^{\times}$ is just the collection of residue classes of $\mathbb{Z}/n\mathbb{Z}$ which have a multiplicative inverse in $\mathbb{Z}/n\mathbb{Z}$.
$\varphi(n)$ is Euler's totient function, as is popularly known. It is not defined using $|(\mathbb{Z}/n\mathbb{Z})^{\times}| = \varphi(n)$ in this text. Rather it is defined as $\varphi(n) = |\{a\in\mathbb{N}: a\leq n, (a,n)=1 \}|$, i.e. number of positive integers less than and co-prime with $n$. $(a,n) = 1$ stands for $\operatorname{g.c.d}(a,n) = 1$.
We have not yet shown that

$(\mathbb{Z}/n\mathbb{Z})^{\times} = \{\bar a \in \mathbb{Z}/n\mathbb{Z} : (a,n) = 1\}$

so please do not use this in your proof. Knowing this, it is trivial, but in a later exercise, we are supposed to prove this using $|(\mathbb{Z}/n\mathbb{Z})^{\times}| = \varphi(n)$ - so let's avoid circular arguments.
Could someone please point me in the right direction? Thanks!
HINT. Note that a solution of
$$
{\displaystyle ax\equiv 1{\pmod {m}}.}
$$
exists if and only if $\gcd(a, m) = 1$.
Proof: Let $x$ be the solution. This is the same thing as saying $ax + my = 1$ for some $y \in \mathbb{Z}$. But if $a$ and $m$ have a common factor $d$, then clearly $d$ divides $1$. This indicates that $d = \pm 1$, so the $\gcd$ of $a$ and $m$ must be $1$. More information here.
Unequivocally the key here is that we have Bézout's identity, which gives equivalence between the statements $(a,b)=1$ and the existence of $x,y$ such that $ax+by=1$.
The nontrivial direction is proved by using the extended Euclidean algorithm.