0% found this document useful (0 votes)
6 views

RSA Encryption

Article about RSA Encryption and Number Theory,

Uploaded by

Songmaster
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

RSA Encryption

Article about RSA Encryption and Number Theory,

Uploaded by

Songmaster
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

The Mathematics Behind RSA Encryption

Sanjhay Vijayakumar
December 24, 2023

1 Introduction
RSA encryption algorithm, also known as Rivest-Shamir-Adleman encryption algorithm is used widely
in cryptography as an assymetric algorithm. An assymetric algorithm uses two keys, public and private
where public is able to encrypt any data sent by the sender and the private key is the key that is able to
decrypt the data sent to them but is only available to the receiver to prevent any eavesdropping. This
article will explore the use of number theory in the encryption process, disadvantages and advantages
as well as possible solutions to overcome the encryption.

1.1 The Algorithm


It is imperative to note that the algorithm is based on the fact that multiplying two large numbers is
easy but factorising a large number is much more difficult. Firstly, the receiver i.e the person wanting
to send data chooses two large prime numbers, namely p and q. Let their product n = pq be the first
half of the public key. To remind us, this key is what will encrypt the data. After, we then use the
Euler’s Totient function denoted by ϕ(n). The Totient function counts the number of positive integers
less than n that are also coprime to n. m ∈ a such that 1 ≤ m < n and gcd(m, n) = 1. Say we have
ϕ(7), then numbers, 1, 2, 3, 4, 5, 6 will be listed where m is relatively prime to n so therefore ϕ(7) =
6. The receiver calculates that ϕ(pq) = (p − 1)(q − 1). We know this because firstly, we list integers,
p, 2p, 3p, ....(q − 1)p that have a common factor with n. Therefore, another list, q, 2q, 3q...(p − 1)q also
have a common factor with n so these must be eliminated from the n − 1 positive integers that are
less than n. The first list has q − 1 exceptions and the second list has p − 1 exceptions and therefore
n − 1 − (p − 1) − (q − 1) = pq − p − q + 1 = (p − 1)(q − 1) positive integers that are less than but also
relatively prime to n. We have now proven this: ϕ(pq) = (p − 1)(q − 1) so the next step is choosing a
number e which is relatively prime to ϕ(pq) and this will be the second half of the public key. Let us
denote m as the plain text. Using c ≡ me (
modn) we can then get the encrypted message as denoted by c. What will be told to the sender is
n and e. c can be formed with those two values and m, the plain text. The receiver also solve this
equation, de ≡ 1(
modϕ(n) where d is the private key.

1.2 Process
To quickly summarise, the sender is able to use the ASCII table to map his letters into numbers and
then using c ≡ me ( mod n), we get the encrypted message, c otherwise known as ciphertext. Then,
using cd ≡ m( mod n), we can get the number, m which can then be unwrapped back to its original
letter. Another approach can be as follows: de ≡ 1( mod (p − 1)(q − 1)) where e is the second half
of the public key and p, q are unique prime numbers. Solving the equation to get d and plugging into
equation cd ( mod n) ≡ m where m is plain text. Let us calculate this with actual values:

p = 23, q = 41

n = pq = 23 ∗ 41 = 943
(p − 1)(q − 1) = 880

1
Let us choose a number that is coprime to 880:e = 7 Suppose m = 35

(c = 357 ( mod 943)

(351 ( mod 943) = 35


(352 ( mod 943) = 1225( mod 943) = 282
4 2
(35 ( mod 943) = 282 ( mod 943) = 79524( mod 943) = 312
7 4 2
(35 = 35 ∗ 35 ∗ 351( mod 943) = 35 ∗ 282 ∗ 312( mod 943) = 3079440( mod 943) = 545

7d ≡ 1( mod 880)
We can solve this using the Euclidean and Extended Euclidean Algorithm.

880x + 7y = 1

880 = 7(1) ∗ 125 + 5


7 = (5) ∗ 1 + 2
5 = (2) ∗ 2 + 1
1 = 5 − 2(2)
1 = 5 − 2(7 − 1(5))
1 − 3(5) − 2(7)
1 = 3(880 − (7) ∗ 125) − 2(7)
1 = 3(880) − 377(7)
880 − 377 = 503
d = 503
Now, to finally de-crypt into plain text, we can either use a very powerful computer or use intricate
mathematical techniques.

545503 ( mod 943)


Notice that 503 = 256 + 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1. Therefore:

545503 = 545256+128+64+32+16+8+4+2+1 = 545256 ∗ 545128 ∗ 54564 ....5451


We can then follow a technique that was previously used above. For example, 5452 = 5451 ∗ 5451 or
another example would be 5458 = 5454 ∗ 5454

5451 ( mod 943) = 545

5452 ( mod 943) = 923


4
545 ( mod 943) = 400
8
545 ( mod 943) = 633
16
545 ( mod 943) = 857
54532 ( mod 943) = 795
64
545 ( mod 943) = 215
128
545 ( mod 943) = 18
256
545 ( mod 943) = 324
503
545 ( mod 943) = 324 ∗ 18 ∗ 215 ∗ 795 ∗ 857 ∗ 633 ∗ 400 ∗ 923 ∗ 545( mod 943) = 35
m = 35
This matches the value that was sent by the sender therefore is correct.

2
1.3 Proof
Firstly, we are proving this statement. Let us remind ourselves of the symbols again for convenience.
Plain text, encrypted message, first half of public key and second half of public key, first prime number
and second prime number are denoted by m, c, n, e, pandq. If me ( mod n) ≡ c is true and n = pq
and p + q are prime and de ≡ 1( mod ϕ) where ϕ = (p − 1)(q − 1) and 1 < e < ϕ and e and
phi are co-prime then cd ( mod n) ≡ m.

de ≡ 1( mod (p − 1)(q − 1)
←→ ∃k ∈ Z : de ≡ (p − 1)(q − 1)k + 1
We are given that
axy ≡ (ax ( mod n)y )( mod n)
p−1∗q−1 p−1 q
m ≡ [(m ( mod p)) − 1( mod p)]
We also know that given p is prime, ∀x : x ̸≡ 0( mod p)
mp−1 ( mod p) ≡ 1
1q−1 ( mod p)
1( mod p)
·
··m
p−1∗q−1
≡ 1( mod p)
p−1∗q−1
m ≡ 1( mod q)
We are given that if p + q are coprime and if x ≡ y( mod p) and x ≡ y( mod q) then x ≡ y(
mod pq)
··· m
p−1∗q−1
≡ 1( mod pq)

me mod n ≡ c
e
←→ m ≡ c( mod n)
Given that
ax ≡ (a( mod n))x ( mod n)
←→
e d
(m ) ≡ (c( mod n))d ( mod n)
Given that
axy ≡ ((ax ( mod n))y ( mod n)
ed d
←→ m ≡c ( mod n)
Given that
de ≡ (p − 1)(q − 1)k + 1
p−1∗q−1∗k+1
←→ m ≡ cd ( mod n)∃k ∈ Z
d p−1∗q−1∗k
←→ c ≡ m ∗ m1 ( mod n)
Given that
(ax ≡ (ay ( mod n)ax−y )( mod n)
d p−1∗q−1∗k
←→ c ≡ m ( mod n) ∗ m)( mod n)
d p−1∗q−1 k
←→ c ≡ (((m ( mod n)) ∗ m)( mod n)
d p−1∗q−1 k
←→ c ≡ ((m ( mod pq)) ∗ m)( mod n)
Due to:
mp−1∗q−1 ≡ 1( mod pq)
d k
c ≡ ((1 ) ∗ m)( mod n)
d
←→ c ≡ m( mod n)
d
←→ c ( mod n) ≡ m
Q.E.D

3
1.4 Advantages and Disadvantages
There are numerous advantages and disadvantages. The advantages are seemingly obvious but vital
to consider for one point is that there is no means to exchange a secret key, otherwise known as the
private key. It is also easy to implement mathematically and because of the fact that it involves very
large numbers, it is very hard to decrypt the cipher text back into plain text. However, in the era
that is to come, we see that an algorithm known as the Euclidean algorithm, that of which was used
above, can compute the greatest common divisor of two numbers and if the GCD ̸= 1, then the public
keys can be broken simultaneously. Also, if me < n then the private key can easily be determined.
Another important to disadvantage would be the use of quantum computers which use algorithms that
are able to factor numbers at a faster complexity than other hardware. In particular, an algorithm
named Shor’s would used in the quantum computer

1.5 Applications and Uses of RSA


RSA is a widely used and known algorithm seen throughout many applications, some of which may be
used be all of us. Examples include digital signatures, secure communication protocols like HTTPS
and SSH, software protection, email encryption, as well as online banking.

You might also like