Name :BRIAN
MATH HL INTERNAL ASSESSMENT
How Does Modular Arithmetic Enhance the Security of the RSA
Encryption Algorithm?
Word count.
Candidate code
INTRODUCTION
In today's digital world,many people find it difficult to protect information from other.with
the fast rate of digitalization company database have often be invaded by criminal to transfer
information to owner area which poses a problem in society this problem can solve in many
way.One way of solving this problem is using arithmetic enhance of Security of the RSA.
This method involve the uses of encryption and decryption of data.To prevented access to
data by on authorised person.This method was (named after inventors rivest,shamir ,and
adleman)
Figure: Image showing the cumulative property of RSA encryption [2]
With this question, I hope to have a deeper understanding of how modular arithmetic is used
in cryptography and its significance in securing digital communication. Employing small
numbers for illustration, I will present the RSA algorithm step by step, test its commutative
property, and discuss its merits and demerits. This question not only identifies the elegance of
RSA but also highlights the power of mathematics in resolving practical cybersecurity issues.
RATIONALE.
In the modern digital age, information security is more crucial than ever. Encryption schemes,
such as RSA (Rivest Shamir Adleman), guard secret information by rendering it unreadable
to unauthorized individuals. RSA uses modular arithmetic, a branch of mathematics
concerned with remainders, to provide security. The basis for the strength of RSA lies in the
computationally difficult task of factoring large numbers into primes, which with present-day
technology is virtually impossible. This experiment is about how modular arithmetic keeps
RSA safe. With tiny figures, I shall demystify the principal stages of RSA—key creation,
encryption, and decryption—to make it understandable on how it operates. I will also attempt
using the commutative property of RSA, which allows for encryption and digital signing
using the same keys. Such a property plays a fundamental role in processes such as secure
communication and document validation.
AIM.
This research aims to study how modular arithmetic enhances the security of encryption
schemes, such as the RSA algorithm. Specifically, I will:
1)Study the mathematical basis of RSA, i.e., key generation, encryption, decryption, in terms
of modular arithmetic.
2)Demonstrate the RSA algorithm step-by-step with small primes to outline the process of
encryption and decryption.
3)Test the RSA commutative property, i.e., if the same keys can be used for encryption and
also digital signatures.
4)Assess the strengths and weaknesses of RSA, particularly that it relies on the difficulty of
factoring large numbers and also its vulnerability to quantum computing.
5)Show practical examples of the use of RSA, e.g., secure messaging and digital signatures,
and analyze its importance in modern cybersecurity.
By achieving these objectives, I will gain a deeper appreciation of the role played by modular
arithmetic in cryptography and how it helps ensure the security of digital communication.
METHODOLOGY.
In this solution, I will outline the methods used to study RSA encryption and decryption
using modular arithmetic. To facilitate computation in this study, I am applying small
numbers for simplicity and readability, but the same principle applies to large numbers used
in our world applications.
Table of formulas and values
Variable Description Formula/Relationship
p,q Two distinct prime numbers n=p×q
Modulus used in encryption and
n n=p×q
decryption
Ф(n) Euler’s totient function ϕ(n) = (p − 1)(q − 1)
Public key exponent (must be
e coprime with 1< e < ϕ(n), gcd(e,ϕ(n)) = 1
ϕ(n))
Private key exponent (must be
d coprime with d×e ≡ 1(modϕ(n))
ϕ(n))
M Plaintext message (integer) 0 ≤ M <n
C Ciphertext (encrypted message) C ≡ M (mod n)
e
M
Decrypted message (original
plaintext)
M ≡ C (modn)
d
Table 1: Table showing values and formulas used [1].
A)Key Generation.
Two prime numbers, p, and q, are chosen to generate the key.
These numbers are computed to make n, the modulus in encryption
n=p×q
ϕ(n) = (p -- 1)(q -- 1)
The public key, e, is computed with d(the private key) using the modular inverse equation:
d × e ≡ 1(modϕ(n))
B)Encryption.
The message, M, is then converted to cipher text, C using the formula:
C≡M e
(mod n)
Although the calculation is simple, a tremendous amount of computer power is required to
perform this operation with very large numbers (hundreds or thousands of digits). Since
modular exponentiation is not particularly difficult, it is extremely hard to do this
backwards—that is, determine M from C, e, and n—without the private key. This is the basis
of RSA's security.
Decryption
To break the cipher text, C, and reveal the original message, M, I will use the private key
exponent, d, which is mathematically equivalent to the public key exponent, e, and the
modulus, n.
M ≡ C (mod n)
d
The above decryption equation tells us that the plaintext message, M, is obtained by raising
the cipher text, C, to the power of the private key exponent, d, and then multiplying it by the
division remainder when divided by the modulus, n.
C)Testing the cumulative property of RSA encryption.
Cumulative property in RSA means that a message, M, can be encrypted with a public
key e and decrypted with a private key, d. Similarly, it also means that M can be
encrypted with the private key and decrypted with the public key. To show that any of
the keys can be employed for encryption while the other is employed for decryption, I
will show that
(M e)d ≡
M (mod n) and (M e)d ≡
M (mod n)
Step 1: Recalling the key relationships.
The public key e and private d key are related by
e⋅d ≡ 1 (modϕ(n))
This means:
e⋅d ≡ k ⋅ ϕ(n) + 1 for some interger k
Step 2: Applying Euler’s theorem.
Euler's theorem informs us that if M and n are coprime, then
M ϕ(n) ≡1(mod n)
Even when M and n are not coprime, the proof holds because of the nature of modular
arithmetic in RSA. The message, M, is not necessarily coprime with n in RSA. Still, the RSA
works. The reason is the specific design of 'n' being the product of two enormous prime
numbers, 'p' and 'q'.
n = p∗q
ϕ(n) = ( p−1 ) ( q−1 )
The encryption and decryption steps are designed in a way that the nature of modular
arithmetic allows us to recover the message even if it is not coprime with n.
Step 3: Proving that (M e)d ≡
M (mod n).
To do this, I will start by separating the powers in (M e)d:
(M e)d = (M e*d )
Then substitute e⋅d ≡ k ⋅ ϕ(n) + 1 from step 1 above:
M e*d = M k * ϕ(n) + 1
M e*d = M k * ϕ(n) (M 1)
Simplifying the Euler’s theorem:
M e*d = ( M ϕ(n) ) k (M 1)
M e*d = ( 1 ) k (M 1)
M e*d = M (mod n )
This will therefore prove that: (Me)d ≡
M (mod n)
Step 4: Proving that (Md)e ≡
M (mod n)
Using the cumulative property of multiplication between the powers implies that:
(Md)e = M d*e
(Md)e = M e*d
Substituting M e*d = M (mod n ) from step 3 above:
( M d )e = M (mod n
The 4 steps above will be followed systematically to test the cumulative property of the RSA
encryption using an example calculation below.
Figure 2: Image showing the cumulative property of RSA encryption [2]
Application/ Sample calculation.
A)Key Generation.
For the key generation, I chose 2 prime numbers.
Let p = 3 and q = 11
‘These numbers are then multiplied to give n
n=p×q
n = 3 × 11
n = 33
The values of p and q are then computed using the totient formula to form the totient of
n(ϕ(n)).
ϕ(n) = (p − 1)(q − 1)
ϕ(n) = (3 − 1)(11 − 1)
ϕ(n) = (2 × 10)
ϕ(n) = 20
Choosing the public key exponent e must satisfy the condition:
1< e < ϕ(n) and gcd(e,ϕ(n)) = 1.
In other words, e and ϕ(n) are both prime numbers with the greatest common factor of 1
Let e = 3 (since gcd(3, 20) = 1).
Computing the modular inverse of e using modulo phin:
d × e ≡ 1(mod ϕ(n))
3(d) ≡ 1(mod 20)
Using the extended Euclidean formula algorithm:
20 = 6 × 3 + 2
3=1 ×2 + 1
2=2 ×1 + 0
Working backward in order to get d:
1=3 −3 × 2
1 = 3 − 3 × (20 − 6 × 3)
1 = 7 × 3 − 1 × 20
Thus, d = 7
Public key: (e, n) = (3, 33)
Private key:(d, n) = (7, 33)
B)Encryption.
Let the message, M = 5 which satisfies ( 0 ≤ 𝑀 < 𝑛).
Encrypting M using the public key:
𝐶 ≡ 𝑀e (mod n)
𝐶 ≡ 53 (mod 33)
𝐶 ≡ 125 (mod 33)
𝐶 ≡ 125 − 3 × 33 (mod 33)
𝐶 ≡ 26
So, the ciphertext C = 26.
C)Decryption.
i)Simplifying 267 (mod 33) using modular exponentiation.
I applied the modular exponentiation approach to calculate 267 (mod 33). This simplifies the
calculation by dividing the exponent into powers of two. I computed 262 (mod 33) first,
followed by 264 (mod 33), and then I added up the results to get 267 (mod 33).
M ≡ C (modn)
d
M ≡ 267 (mod 33)
267 (mod 33) ≡ (262 (mod 33)) × (264 (mod 33)) ×( 26 (mod 33))
267=264× 262× 261 (mod 33)
262 ≡ 676 (mod 33) 264 ≡ (262)2
262 ≡ 676 – 20 × 33 264 ≡ 162 (mod 33)
262 ≡ 676 – 660 264 ≡ 256 – 7 × 33
262 ≡ 16 (mod 33) 264 ≡ 25 (mod 33)
267=264× 262× 261 (mod 33)
Next, I performed the modular multiplications step-by-step. First, I multiplied 25 and 16, then
took the result modulo 33. Following this, I multiplied the result by 26 and again took the
result modulo 33.
(25×16) (mod 33) = 400 (mod 33)
= 400 − 12 × 33
=4(mod33)
(4×26) (mod 33 ) = 104 (mod 33)
≡ 104 − 3 × 33
= 5(mod33)
Therefore, M ≡ 5 (mod33), which confirms that the decrypted message is 5, matches the
original message.
M ≡ 5(mod33)
E) Testing the commutative property.
I carried out the decryption and encryption operations in reverse order to illustrate the
commutative property of decryption and encryption in RSA. I used the private key, d, to
encrypt the original message, M = 5, first and then used the public key, e, to decrypt the
ciphertext produced. If the commutative property is true, this operation should result in the
original message.
i) Encryption with d( the decryption key)
I encrypted M = 5 using the private key, d = 7, and the modulus, n = 33, using the formula for
encryption with the decryption key, d, instead of e, the encryption key.
Cd ≡ M (mod n). This resulted in C′ ≡ 57
(mod 33).
Cd ≡ M d (mod n)
Cd ≡ 57 (mod 33)
To compute 57 (mod 33), I again used modular exponentiation. I calculated 52 (mod 33), then
54 (mod 33 ), and finally combined these results to find 57 ( mod 33).
52 ≡ 25 (mod33)
54 ≡ (52)2
54 ≡ 252(mod33)
54 ≡ 625(mod33)
54 ≡ 625 − 18×33
54 =31(mod 33)
57 ≡ 54 × 5 2× 5(mod 33)
57 ≡ 31 × 25 × 5 (mod 33)
I then performed the modular multiplications step-by-step. First, I multiplied 31 and 25, then
took the result modulo 33. Following this, I multiplied the result by 5 and again took the
result modulo 33.
31 × 25 = 775
31 × 25 ≡ 775 −23 × 33
31 × 25 = 775 − 759
31 × 25 = 16 (mod33)
16 × 5 = 80 ≡ 80 − 2 × 33
16 × 5 = 14(mod33)
Thus, Cd = 14.
Cd = 14
ii) Decryption with e
Next, I decrypted Cd =14 using the public key, e = 3, and the modulus, n
=33, with the use of the formula M ≡ Ce (mod n) but using the cipher
t. This resulted in M ≡ 143(mod 33).
M ≡ Cd (modn)
M ≡ 143 (mod33)
M ≡ 2744 ( mod33 )
M ≡ 2744 − 83 × 33
M = 2744 − 2739
M = 5( mod33 )
Therefore, M ≡ 5(mod 33), which matches the original message. This confirms the
commutative property of RSA encryption and decryption.
M ≡ 5(mod33)
F) Analysis and Evaluation.
Analysis of the RSA algorithm.
I was able to adequately illustrate the RSA algorithm in this research by the use of small
prime numbers. The correctness of the algorithm was guaranteed from the results derived
from the stepwise key generation, encryption, and decryption processes. Using the public key
(e, n) = (3, 33), the original message M = 5 was enciphered as C = 26 and was deciphered
again as M = 5 from the private key (d, n) = (7, 33). This verified that the RSA algorithm was
working correctly.
I also used the private key d = 7 to encrypt the message M = 5 and the public key e = 3 to
decrypt it in an attempt to demonstrate the commutative property of RSA. The original
message
M = 5 was the outcome, which confirmed that RSA satisfies the commutative property. This
property is essential in applications such as digital signatures, where a message is encrypted
(signed) using the private key and decrypted (verified) using the public key.
i) Strength of the RSA
Relying on the difficulty of factoring big numbers is one of RSA's key advantages. I used the
small prime numbers p = 3 and q = 11 in my investigation for simplicity's sake, but in
practical applications, p and q are incredibly large (hundreds or thousands of digits). The
product n = p × q cannot be factored into its prime components using current technology,
which makes RSA extremely secure.
An additional advantage is the algorithm's mathematical elegance. The encryption and
decryption procedures are made safe and effective by utilizing Euler's theorem, modular
arithmetic, and the characteristics of prime numbers. Because of its commutative property,
RSA is even more versatile and can be used for digital signatures as well as encryption.
ii) Limitations of the RSA
RSA has certain drawbacks in spite of its advantages. Its computational complexity,
particularly for large keys, is one of its main drawbacks. Modular exponentiation, which is
used in the encryption and decryption procedures, can be computationally costly for very
large numbers. Because of this, RSA is slower than symmetric-key algorithms like AES,
particularly when encrypting large volumes of data.
Its susceptibility to quantum computing is another drawback. Quantum computers may be
able to crack RSA by effectively factoring big numbers using Shor's algorithm, even though
RSA is safe from classical computers. As a result, post-quantum cryptography was developed
with the goal of developing encryption algorithms that are impervious to quantum attacks.
iii) Real-world applications
RSA has certain drawbacks in spite of its advantages. Its computational complexity,
particularly for large keys, is one of its main drawbacks. Modular exponentiation, which is
used in the encryption and decryption procedures, can be computationally costly for very
large numbers. Because of this, RSA is slower than symmetric-key algorithms like AES,
particularly when encrypting large volumes of data.
Its susceptibility to quantum computing is another drawback. Quantum computers may be
able to crack RSA by effectively factoring big numbers using Shor's algorithm, even though
RSA is safe from classical computers. As a result, post-quantum cryptography was developed
with the goal of developing encryption algorithms that are impervious to quantum attacks.
iv) Reflection on the exploration
I now have a better understanding of how modular arithmetic serves as the basis for RSA
encryption thanks to this investigation. I was able to better understand the algorithm's
underlying mathematical concepts, including Euler's theorem and prime number properties,
thanks to the detailed computations. I also learned about the possible dangers of quantum
computing and how crucial key size is to maintaining security.
Using modular exponentiation to simplify large exponents was one of the challenges I
encountered. At first, I had trouble breaking down 2 6 7 (m o d 33) 26 7 (mod33) into smaller
steps, but I was able to successfully simplify the calculation by applying the exponentiation
by squaring method. The significance of effective algorithms in cryptography was brought
home by this experience.
Conclusion
In summary, the mathematical underpinnings of the RSA algorithm and its use in encryption
and decryption were illustrated by this investigation. In addition to analyzing the algorithm's
advantages and disadvantages, the commutative property of RSA was successfully
confirmed. RSA's weaknesses in quantum computing underscore the necessity of continuous
research into new cryptographic techniques, even though it is still a fundamental component
of contemporary cryptography. My understanding of modular arithmetic and its crucial role
in cybersecurity has grown as a result of this investigation.
References
[1] Formulae for RSA cryptography taken from
( https://www.geeksforgeeks’.org/rsa-algorithm-cryptography )
[2] Image showing the cumulative property of RSA encryption
( https://dcmsys.com/project/dicom-encryption-anonymization/ )