Skip to main content
correct Fermat -> Euler, prettify math notation, misc. copyedits
Source Link
Ilmari Karonen
  • 46.5k
  • 5
  • 111
  • 187

RSA encryption and decryption is built upon Fermat's theoremEuler's theorem which says: that $a^{\phi(n)} = 1 \mod(n)$$a^{\phi(n)} \equiv 1 \pmod n$, and since $p$ and $q$ are primes:, $\phi(p*q) = (p-1)*(q-1)$$\phi(pq) = (p-1)(q-1)$.

If we have message $M$ and, modulus $n$, private keyexponent $d$ and public pairexponent $e$, RSA encryption works like this:

Encryption: $C = M^e (\mod n)$
Decryption: $C^d \mod(n)$ which most be the same as $M$

  • Encryption: $C = (M^e \bmod n)$
  • Decryption: $M' = (C^d \bmod n)$, which must be the same as $M$ for the decryption to be correct.

Now, combining the above, we get $C^d = (M^e)^d = M^{(ed)} \mod(n)$.$$M' \equiv C^d \equiv (M^e)^d = M^{ed} \pmod n.$$ Since $ed = 1 \mod \phi(n)$$ed \equiv 1 \mod{\phi(n)}$, we may write $K*\phi(n) = ed - 1$$k\cdot\phi(n) = ed - 1$ for some integer $k$ which renders itand rearrange this to $ed = k*\phi(n) + 1$$ed = k\cdot\phi(n) + 1$.

NowTherefore $M^{(ed)} = M^{(\phi(n) + 1 )} = M*M^{(phi(n))} \mod(n)$,$$M' \equiv M^{ed} = M^{k\phi(n) + 1} = M \cdot M^{k\phi(n)} \pmod n,$$ and since $M^{(\phi(n))} = 1 \mod(n)$$$M^{k\phi(n)} = (M^{\phi(n)})^k \equiv 1^k = 1 \pmod n,$$ the decryption result becomes $M$$M' \equiv M \cdot M^{k\phi(n)} \equiv M \cdot 1 = M \pmod n$ equals the original message again.

So, withoutAll this depends crucially on the fact that $ed=1 \mod(\phi(n))$$ed=1 \mod{\phi(n)}$, so without it, we wontwon't get $M$ back when we decrypt.

RSA encryption and decryption is built upon Fermat's theorem which says: $a^{\phi(n)} = 1 \mod(n)$, and since $p$ and $q$ are primes: $\phi(p*q) = (p-1)*(q-1)$.

If we have message $M$ and private key $d$ and public pair $e$

Encryption: $C = M^e (\mod n)$
Decryption: $C^d \mod(n)$ which most be the same as $M$

Now, $C^d = (M^e)^d = M^{(ed)} \mod(n)$. Since $ed = 1 \mod \phi(n)$, we may write $K*\phi(n) = ed - 1$ for some integer $k$ which renders it to $ed = k*\phi(n) + 1$.

Now $M^{(ed)} = M^{(\phi(n) + 1 )} = M*M^{(phi(n))} \mod(n)$, and since $M^{(\phi(n))} = 1 \mod(n)$ the result becomes $M$ the message again.

So, without the fact that $ed=1 \mod(\phi(n))$ we wont get $M$ back.

RSA encryption and decryption is built upon Euler's theorem which says that $a^{\phi(n)} \equiv 1 \pmod n$, and since $p$ and $q$ are primes, $\phi(pq) = (p-1)(q-1)$.

If we have message $M$, modulus $n$, private exponent $d$ and public exponent $e$, RSA encryption works like this:

  • Encryption: $C = (M^e \bmod n)$
  • Decryption: $M' = (C^d \bmod n)$, which must be the same as $M$ for the decryption to be correct.

Now, combining the above, we get $$M' \equiv C^d \equiv (M^e)^d = M^{ed} \pmod n.$$ Since $ed \equiv 1 \mod{\phi(n)}$, we may write $k\cdot\phi(n) = ed - 1$ for some integer $k$ and rearrange this to $ed = k\cdot\phi(n) + 1$.

Therefore $$M' \equiv M^{ed} = M^{k\phi(n) + 1} = M \cdot M^{k\phi(n)} \pmod n,$$ and since $$M^{k\phi(n)} = (M^{\phi(n)})^k \equiv 1^k = 1 \pmod n,$$ the decryption result $M' \equiv M \cdot M^{k\phi(n)} \equiv M \cdot 1 = M \pmod n$ equals the original message.

All this depends crucially on the fact that $ed=1 \mod{\phi(n)}$, so without it, we won't get $M$ back when we decrypt.

Introduced MathJax for the formulas, some minor language fixes.
Source Link
e-sushi
  • 18.1k
  • 12
  • 85
  • 235

RSA encryption and decryption is built upon FermatsFermat's theorem which says: a^phi(n) = 1 mod(n) $a^{\phi(n)} = 1 \mod(n)$, and since p$p$ and q$q$ are primes
phi(p*q) = (p-1)*(q-1)
if: $\phi(p*q) = (p-1)*(q-1)$.

If we have message M$M$ and private key d$d$ and public pair e:
Encryption: C = M^e (mod n)$e$

Encryption: $C = M^e (\mod n)$
Decryption:Decryption: C^d mod(n)$C^d \mod(n)$ which most be the same as M
Now C^d = (M^e)^d = M^(ed) mod(n)
since$M$

Now, ed = 1 mod phi(n)$C^d = (M^e)^d = M^{(ed)} \mod(n)$. Since $ed = 1 \mod \phi(n)$, we may write K*phi(n) = ed - 1$K*\phi(n) = ed - 1$ for some integer k
now ed = k*Phi(n) + 1
now$k$ which renders it to M^(ed) = M^(phi(n) + 1 ) = M*M^(phi(n)) mod(n)
since$ed = k*\phi(n) + 1$.

Now M^(phi(n)) = 1 mod(n)$M^{(ed)} = M^{(\phi(n) + 1 )} = M*M^{(phi(n))} \mod(n)$, and since $M^{(\phi(n))} = 1 \mod(n)$ the result becomes M$M$ the message again :) so.

So, without the fact that ed=1 mod(phi(n))$ed=1 \mod(\phi(n))$ we wont get M$M$ back.

RSA encryption and decryption is built upon Fermats theorem which says: a^phi(n) = 1 mod(n) and since p and q are primes
phi(p*q) = (p-1)*(q-1)
if we have message M and private key d and public pair e:
Encryption: C = M^e (mod n)
Decryption: C^d mod(n) which most be the same as M
Now C^d = (M^e)^d = M^(ed) mod(n)
since ed = 1 mod phi(n), we may write K*phi(n) = ed - 1 for some integer k
now ed = k*Phi(n) + 1
now M^(ed) = M^(phi(n) + 1 ) = M*M^(phi(n)) mod(n)
since M^(phi(n)) = 1 mod(n) the result becomes M the message again :) so without the fact that ed=1 mod(phi(n)) we wont get M back

RSA encryption and decryption is built upon Fermat's theorem which says: $a^{\phi(n)} = 1 \mod(n)$, and since $p$ and $q$ are primes: $\phi(p*q) = (p-1)*(q-1)$.

If we have message $M$ and private key $d$ and public pair $e$

Encryption: $C = M^e (\mod n)$
Decryption: $C^d \mod(n)$ which most be the same as $M$

Now, $C^d = (M^e)^d = M^{(ed)} \mod(n)$. Since $ed = 1 \mod \phi(n)$, we may write $K*\phi(n) = ed - 1$ for some integer $k$ which renders it to $ed = k*\phi(n) + 1$.

Now $M^{(ed)} = M^{(\phi(n) + 1 )} = M*M^{(phi(n))} \mod(n)$, and since $M^{(\phi(n))} = 1 \mod(n)$ the result becomes $M$ the message again.

So, without the fact that $ed=1 \mod(\phi(n))$ we wont get $M$ back.

Source Link
Monim
  • 259
  • 1
  • 4

RSA encryption and decryption is built upon Fermats theorem which says: a^phi(n) = 1 mod(n) and since p and q are primes
phi(p*q) = (p-1)*(q-1)
if we have message M and private key d and public pair e:
Encryption: C = M^e (mod n)
Decryption: C^d mod(n) which most be the same as M
Now C^d = (M^e)^d = M^(ed) mod(n)
since ed = 1 mod phi(n), we may write K*phi(n) = ed - 1 for some integer k
now ed = k*Phi(n) + 1
now M^(ed) = M^(phi(n) + 1 ) = M*M^(phi(n)) mod(n)
since M^(phi(n)) = 1 mod(n) the result becomes M the message again :) so without the fact that ed=1 mod(phi(n)) we wont get M back