I'm trying to understand the RSA cryptosystem, and that's what I know so far:
If we think about some number $m$ as the message, then we are searching a $e$ and $d$ such that
$$m^{ed} \equiv m \ \ (\mbox{mod} \ n)$$
So someone can encrypt the message by doing $$m^e \ \ (\mbox{mod} \ n)$$ And the person that holds $d$ can decrypt it by doing
$$(m^e \ \ (\mbox{mod} \ n))^d (\mbox{mod}\ n) = m$$ *(not the best notation but you guys get the idea)
$d$ can be calculated by using Euler's theorem, which states that:
$$m^{\phi(n)}\equiv 1 \ (\mbox{mod} \ n) \tag{2}$$
where $m$ coprime with $n$
Then, by some modular arithmetic properties, we can do this in $(2)$:
Raise both sides by $k$, so we get:
$$m^{k\phi(n)}\equiv 1 \ (\mbox{mod} \ n)$$ *because $1^k$ is $1$
Then multiply both sides by $m$:
$$m^{k\phi(n)+1}\equiv m \ (\mbox{mod} \ n)$$
By comparing this congruency with the one we've been searching:
$$m^{k\phi(n)+1}\equiv m \ (\mbox{mod} \ n)$$
$$m^{ed} \equiv m \ \ (\mbox{mod} \ n)$$
We just need to solve for $d$ by doing:
$$ed = k\phi(n)+1\implies d = \frac{k\phi(n)+1}{e}$$
So $d$ can be easely calculated if you know the factorization of $n$, because for a number $n$, $\phi(n)$ is $\phi(p)\phi(q)$ where $n = pq$ (in other words, $p$ and $q$ are the prime factors of $n$). So since we think (for centuries) that factorization of large numbers is a difficult problem, we assume that no one will be able to find $d$ in a reasonable amount of time, unless they know wich prime numbers form $n$.
My questions are:
I don't know if I understand that the requirement that $e$ is a prime number. For me, any number would work in the process I described.
Also, why $m$ is not assumed to be coprime with $n$ at $(2)$? Since $m$ is the message, it can happen that $m$ is not coprime with $n$.
In the wikipedia article, it says that $e$ must be less that $\phi(n)$. Why?
Why, in the wikipedia article where he proves it using fermat's little theorem, it assumes that $ed$ is congruent to $1$ mod $\phi(n)$?
I've seen all this at khan academy, but the process they described does not answer my questions. I would like some help with the intuition, as always. I'm not looking for some one line proof, so please help me understand the requirement that $e$ is prime, for example, by using the process I described.
Please be patient, I'll give time to choose the answers, so you guys have time to write a good one <3