logo

Proof of the RSA Public Key Cryptosystem 📂Number Theory

Proof of the RSA Public Key Cryptosystem

Buildup

20190703\_130027.png Let’s call them Alice, Bob, and Eve from left to right. Alice and Bob are the parties exchanging messages, and Eve is a passive attacker interested in the message. The orange box represents information only known by Alice, the sky blue box is information only known by Bob, and the black box represents information that is public (also known by Eve).

Alice has a message mNm \in \mathbb{N} she needs to receive from Bob.

Algorithm 1

Key Setup: Alice selects and publishes a large prime number’s product N=pqN=pq which satisfies gcd(e,(p1)(q1))=1\gcd \left( e , (p-1)(q-1) \right) = 1 and ee.

20190703\_130618.png


Encryption: Bob computes cme(modN)c \equiv m^{e} \pmod{N} and makes it public.

20190703\_131106.png


Decryption: Alice finds dd that satisfies de1(mod(p1)(q1))de \equiv 1 \pmod{(p-1)(q-1)} and calculates xcdm(modN)x \equiv c^{d} \equiv m \pmod{N} to obtain x=mx=m. Eve realistically cannot know dd, therefore she cannot know mm.

20190703\_131157.png

Description

The RSA Public Key Cryptosystem was developed by Ronald Rivest, Adi Shamir, and Leonard Adleman and is abbreviated as RSA, named after the first letters of their last names. The three were awarded the Turing Award in 2002 for this achievement.

It is based not only on the difficulty of the discrete logarithm problem like the ElGamal Public Key Cryptosystem but also on the difficulty of the prime factorization problem, making it worthwhile to find large primes just for its robustness. Moreover, it is a system that is fun to study because it’s not just theoretical or outdated but is actually used worldwide today. A potentially fatal attack method is the Shor’s Algorithm, based on quantum computers, but the commercialization of quantum computers is far off, so it will remain active for the foreseeable future.

Proof

Decryption

Alice knows the prime factorization N=pqN = pq of NN, so she can find ee that satisfies gcd(e,(p1)(q1))=1\gcd \left( e , (p-1)(q-1) \right) = 1.

Extended Euclidean Theorem: For two integers a,ba,b, there always exists an integer solution to aX+bY=gcd(a,b)aX + bY = \gcd (a,b).

For two integers ee, (p1)(q1)(p-1)(q-1), eX+(p1)(q1)Y=1 e X + (p-1)(q-1) Y = 1 there exists an integer solution {X=dY=k\begin{cases} X=d \\ Y = - k \end{cases}, which means de=1+k(p1)(q1) de = 1 + k (p-1)(q-1) In other words, dd, i.e., the inverse of ee in the ring Z(p1)(q1)\mathbb{Z}_{(p-1)(q-1)}, and since Alice knows pp, qq, she can easily find dd. [ NOTE: The existence of a multiplicative inverse in a ring is not at all trivial, which highlights the necessity of condition gcd(e,(p1)(q1))=1\gcd \left( e , (p-1)(q-1) \right) = 1. ]

Euler’s Totient Theorem: gcd(a,m)=1    aϕ(m)1(modm) \gcd(a,m) = 1 \implies a^{ \phi (m) } \equiv 1 \pmod{m}

Since gcd(e,(p1)(q1))=1\gcd \left( e , (p-1)(q-1) \right) = 1, the inverse of ee, dd, is found as follows: d=e1=eϕ((p1)(q1))1 d = e^{-1} = e^{\phi \left( (p-1)(q-1) \right) -1} It simply involves exponentiation of ee, so it can be easily and quickly calculated using the exponentiation by squaring method. Let’s consider the case where gcd(c,pq)=1\gcd ( c , pq ) = 1 is satisfied and the case where it is not.


Case 1. gcd(c,pq)=1\gcd ( c , pq ) = 1

It reduces to a problem of finding a modular square root of congruence equations.

Multiplicative property of the Totient function: gcd(p,q)=1    ϕ(pq)=ϕ(p)ϕ(q) \gcd (p , q) =1 \implies \phi ( p q ) = \phi (p) \phi (q)

ϕ(p)=p1\phi (p) = p-1 and ϕ(q)=q1\phi (q) = q-1 so ϕ(pq)=ϕ(p)ϕ(q)=(p1)(q1) \phi (pq) = \phi (p) \phi (q) = (p-1)(q-1)

Euler’s Totient Theorem: gcd(c,N)=1    cϕ(N)1(modN) \gcd(c,N) = 1 \implies c^{ \phi (N) } \equiv 1 \pmod{N}

c(p1)(q1)=cϕ(pq)c^{(p-1)(q-1)} = c^{ \phi (pq ) } so (cd)ecdec1+k(p1)(q1)c(c(p1)(q1))kc1kc(modpq) \begin{align*} \left( c^{d} \right)^{e} & \equiv c^{de} \\ & \equiv c^{1 + k (p-1)(q-1)} \\ & \equiv c \cdot \left( c^{(p-1)(q-1)} \right)^{k} \\ & \equiv c \cdot 1^{k} \\ & \equiv c \pmod{pq} \end{align*}


Case 2. gcd(c,pq)1\gcd ( c , pq ) \ne 1

Cc(p1)(q1)(modpq) C \equiv c^{(p-1)(q-1)} \pmod{pq} If cc is a multiple of pqpq then xe0x^{e} \equiv 0, therefore x=0x = 0 is necessary and meaningless. Hence, assume that cc is a multiple of either pp or qq, but it doesn’t matter which one, so let’s assume it’s a multiple of qq. Then, for some n0Zn_{0} \in \mathbb{Z} and pp not a multiple of some KZK \in \mathbb{Z}, C=c(p1)(q1)+(pq)n0=[qK](p1)(q1)+pqn0 \begin{align*} C =& c^{(p-1)(q-1)} + (pq) \cdot n_{0} \\ =& \left[ qK \right]^{(p-1)(q-1)} + p \cdot q n_{0} \end{align*} there exists qn0q n_{0} satisfying the above equation, so c(p1)(q1)[(qK)q1]p1(modp) c^{(p-1)(q-1)} \equiv \left[ (qK)^{q-1} \right]^{p-1} \pmod{p}

Part 1. (cd)ec(modp)\left( c^{d} \right)^{e} \equiv c \pmod{p}

Fermat’s Little Theorem: For a prime pp and an integer aa relatively prime to pp, ap11(modp)a^{p-1} \equiv 1 \pmod{p}

Since KK is not a multiple of pp, [(qK)q1]\left[ (qK)^{q-1} \right] is relatively prime to pp, (cd)ecdec1+k(p1)(q1)c[(qK)k(q1)]p1c1(modp) \begin{align*} \left( c^{d} \right)^{e} & \equiv c^{de} \\ & \equiv c^{1 + k (p-1)(q-1)} \\ & \equiv c \cdot \left[ (qK)^{k(q-1)} \right]^{p-1} \\ & \equiv c \cdot 1 \pmod{p} \end{align*}

Part 2. (cd)ec(modq)\left( c^{d} \right)^{e} \equiv c \pmod{q}

(cd)ecde[qK]de0qKc(modq) \begin{align*} \left( c^{d} \right)^{e} & \equiv c^{de} \\ & \equiv \left[ qK \right]^{de} \\ & \equiv 0 \\ & \equiv qK \\ & \equiv c \pmod{q} \end{align*}

Part 3. (cd)ec(modpq)\left( c^{d} \right)^{e} \equiv c \pmod{pq}

Multiplication of Modulos: If gcd(m1,m2)=1\gcd ( m_{1} , m_{2} ) = 1 then {ab(modm1)a=b(modm2)    ab(modm1m2)\begin{cases} a \equiv b \pmod{ m_{1} } \\ a = b \pmod{ m_{2} } \end{cases} \implies a \equiv b \pmod{ m_{1} m_{2} }

From Part 1, 2, {(cd)ec(modp)(cd)ec(modq)\begin{cases} \left( c^{d} \right)^{e} \equiv c \pmod{p} \\ \left( c^{d} \right)^{e} \equiv c \pmod{q} \end{cases} is obtained, so we get: (cd)ec(modpq) \left( c^{d} \right)^{e} \equiv c \pmod{pq}


Therefore, x=cdx=c^{d} exists as a solution to xec(modpq)x^{e} \equiv c \pmod{pq} under any circumstances. Also, another solution uu, if it exists, can easily be shown to always appear as ucd(modpq)u \equiv c^{d} \pmod{pq}.

Encryption

Eve knows ee, but to find the inverse dd, she must solve the prime factorization problem N=pqN=pq. Since this is very difficult, Bob can securely transmit the message mm to Alice.

See Also

Security Algorithms Utilizing the Difficulty of Prime Factorization Problem

Attack Algorithms on the Prime Factorization Problem


  1. Hoffstein. (2008). An Introduction to Mathematical Cryptography: p115~122. ↩︎