I am studying the principles of RSA and have come across some unintuitive statements. Lets revisit the RSA algorithm:
RSA Key Generation
Output: public key: $k_{pub} = (n,e)$ and private key: $k_{pr} = (d)$
- Choose two large primes $p$ and $q$.
- Compute $n$ = $pq$.
- Compute $\varphi(n) = (p−1)(q−1)$.
- Select the public exponent $e \in \{1,2,\ldots,\varphi(n)−1\}$ such that $\gcd(e,\varphi(n)) = 1.$
- Compute the private key $d$ such that $d\cdot e \equiv 1 \bmod \varphi(n)$
Decryption: $x=d_{kpr}(y)\equiv y^{d} \bmod n$
Encryption: $y=e_{kpub}(x)\equiv x^{e} \bmod n$
I don't find intuitive on why we perform encryption and decryption in modulus $n$, but compute the inverse of $e$ in modulus $\varphi(n)$. Any help is appreciated.