Congruency in Cryptography Project Report.pdf
Congruency in Cryptography Project Report.pdf
IN
CRYPTOGRAPHY
In the Partial fulfilment of B. Tech – 1 year
Course requirement of
Subject: DISCRETE MATHEMATICS (Course Code: CSE 1705)
By:
PRINCE SINGH YADAV (Sec 1-A) (200149)
ISHITA CHAUHAN (Sec 1-A) (200164)
MONIKA RAGHAV (Sec 1-A) (200281)
DHEERAJ (Sec 1-B) (200330)
INTRODUCTION
Today crime is increasingly on daily basis and takes different forms. The significance of
information in checking this cannot be overemphasized. Not all but some information needs
to be secure from other partners, especially the information or data obtained from internet.
We must know that all information sends by email, third partners are allowed to have access
to the messages that we send (router).
Cryptography has for long been an important issue in computer science. It was mainly used
for the security needed for passwords, but now cryptography is very important due to the
Internet's flow of sensitive information such as credit card information and other sensitive
information which is easy to monitor by unintended third party. The main concern of this
study is messages between two persons and many of the partners between them they want
to communicate with. If X wanted to send a secure message to Y can be achieved by sending
an encrypt message. Then, a key(k) to encrypt and decrypt the message must be known to
only to X and Y.
CONGRUENCE
Congruences are an important and useful tool for the study of divisibility. As we shall see,
they are also critical in the art of cryptography.
a ≡ b mod n
The notation is used because the properties of congruence “≡” are very similar to the
properties of equality “=”.
1. a ≡ a mod n.
These results are classically called: 1. Reflexivity; 2. Symmetry; and 3. Transitivity. The proof
is as follows:
2. If a ≡ b mod n then n|(b − a). Therefore, n|(−1)(b − a) or n|(a − b). Therefore, b ≡ a mod n.
Using the linear combination theorem, we have n|(b − a + c − b) or n|(c − a). Thus, a ≡ c mod
n. The following result gives an equivalent way of looking at congruence. It replaces the
congruence sign with an equality.
1=5 · 5+(−2) · 12
So, both sides of this equality are congruent to each other mod 12. Hence
1 ≡ 5 · 5+(−2) · 12 ≡ 5 · 5 mod 12
5x ≡ 25 ≡ 1 mod 12
How Congruency and Number theory is used in
Cryptography
Cryptography is one of the advanced fields which uses principles of modular arithmetic and
number theory . Congruences play a key role in cryptography, the subject of transforming
information so that it cannot be easily recovered without special knowledge. Number theory
is the basis of many classical ciphers, first used thousands of years ago, and used extensively
until the 20th century. These ciphers encrypt messages by changing each letter to a different
letter, or each block of letters to a different block of letters. We will discuss some classical
ciphers, including shift ciphers, which replace each letter by the letter a fixed number of
positions later in the alphabet, wrapping around to the beginning of the alphabet when
necessary. The classical ciphers we will discuss are examples of private key ciphers were
knowing how to encrypt allows someone to also decrypt messages. With a private key cipher,
two parties who wish to communicate in secret must share a secret key. The classical ciphers
we will discuss are also vulnerable to cryptanalysis, which seeks to recover encrypted
information without access to the secret information used to encrypt the message. We will
show how to cryptanalyze messages sent using shift ciphers.
Number theory and congruences are also important in public key cryptography, a type of
cryptography invented in the 1970s. In public key cryptography, knowing how to encrypt does
not also tell someone how to decrypt. The most widely used public key system, called the RSA
cryptosystem, encrypts messages using modular exponentiation, where the modulus is the
product of two large primes. Knowing how to encrypt requires that someone know the
modulus and an exponent. (It does not require that the two prime factors of the modulus be
known.) As far as it is known, knowing how to decrypt requires someone to know how to
invert the encryption function, which can only be done in a practical amount of time when
someone knows these two large prime factors. In this report we will explain how the RSA
cryptosystem works, including how to encrypt and decrypt messages.
The subject of cryptography also includes the subject of cryptographic protocols, which are
exchanges of messages carried out by two or more parties to achieve a specific security goal.
We will discuss two important protocols in this report. One allows two people to share a
common secret key. The other can be used to send signed messages so that a recipient can
be sure that they were sent by the purported sender.
CLASSIC CRYPTOGRAPHY
In Cryptography, the ‘Caesar cipher’ named after Julius Caesar is one of the earliest known
uses of cryptography. He made his messages secret by shifting each letter three letters
forward in the alphabet and sending the last three letters of the alphabet to the first three.
For instance, using this scheme the letter D is sent to F and the letter Z is sent to C. However,
it is not properly known how effective the Caesar cipher was at the time, but it is likely
considered to have been reasonably secure, not just because most of Caesar's enemies would
have been illiterate but also as others would have assumed that the messages were written
in any unknown foreign language. Here is an example of how encryption (the process of
making a message secret) is done using Caesar’s cipher. To express Caesar’s encryption
process mathematically, first we must replace each letter by an element of Z26, that is, an
integer from 0 to 25 equal to one less than the letter’s position in the alphabet. For example,
replace A by 0, T by 19, and Z by 25. This representation is called the ‘representation using
modular arithmetic’.
A B C D E F G H I J K L M
0 1 2 3 4 5 6 7 8 9 10 11 12
N O P Q R S T U V W X Y Z
13 14 15 16 17 18 19 20 21 22 23 24 25
𝐸𝑛 (𝑥) = (𝑥 + 3) 𝑚𝑜𝑑 26
𝐷𝑛 (𝑥) = (𝑥 − 3) 𝑚𝑜𝑑 26
EXAMPLE: What is the secret message produced from the message “DISCRETE
MATHEMATICS” using the Caesar ciphers?
First replace the letters in the message with numbers. This produces
3 8 18 2 17 4 19 4 12 0 19 7 4 12 0 19 8 2 18
We now apply the shift f (x) = (x + 3) mod 26 to each number in this string. We obtain
6 11 21 5 20 7 22 7 15 3 22 10 7 15 3 22 11 5 21
G L V F U H W H P D W K H P D W L F V
BLOCK CIPHERS
Shift ciphers like the Caesar ciphers, are proceed by replacing each letter of the alphabet by
another letter in the alphabet. Because of this, these ciphers are called character or
monoalphabetic ciphers. These kinds of Encryption methods are vulnerable to attacks based
on the analysis of letter frequency in the ciphertext. We can make it harder to successfully
attack ciphertext by replacing blocks of letters with other blocks of letters instead of replacing
individual characters with individual characters; such ciphers are called Block ciphers.
One simple type of block cipher is the transposition cipher. In transposition cipher, we use a
permutation σ of the set {1, 2, . . . , m} for some positive integer m as a key, that is, a one-to-
one function from {1, 2, . . . , m} to itself. To encrypt a message, we first split its letters into
blocks of size m. (If the number of letters in the message is not divisible by m, we add some
random letters at the end to fill out the final block.) We encrypt the block p 1p2 . . . pm as c1c2
. . . cm = pσ(1)pσ(2) . . . , pσ(m). To decrypt a ciphertext block c1c2 . . . cm, we transpose its letters
using the permutation σ −1, the inverse of σ.
EXAMPLE: Using the transposition cipher based on the permutation σ of the set {1, 2, 3, 4}
with σ(1) = 3, σ(2) = 1, σ(3) = 4, and σ(4) = 2,
(b) Decrypt the ciphertext message SWUETRAE OEHS, which was encrypted using this cipher.
(a)We first split the letters of the plaintext into blocks of four letters.We obtain PIRA TEAT
TACK. To encrypt each block, we send the first letter to the third position, the second letter
to the first position, the third letter to the fourth position, and the fourth letter to the second
position. We obtain IAPR ETTA AKTC.
(b) We note that σ−1, the inverse of σ, sends 1 to 2, sends 2 to 4, sends 3 to 1, and sends 4 to
3. Applying σ−1(m) to each block gives us the plaintext: USEW ATER HOSE. (Grouping together
these letters to form common words, we surmise that the plaintext is USE WATER HOSE.)
CRYPTOSYSTEMS
A cryptosystem is an implementation of cryptographic techniques and their accompanying
infrastructure to provide information security services. A cryptosystem is also referred to as
a cipher system.
Cryptosystems are used for sending messages in a secure manner over the internet, such as
credit card information and other private data. In another application of cryptography, a
system for secure electronic mail might include methods for digital signatures, cryptographic
hash functions and key management techniques. The concept of a cryptosystem is useful in
the discussion of additional families of ciphers and is used extensively in cryptography.
PUBLIC KEY CRYPTOGRAPHY
All classical ciphers, including shift ciphers or the Caesar ciphers , are examples of private key
cryptosystems. In a private key cryptosystem, once you know an encryption key, you can
quickly find the decryption key. So, knowing how to encrypt messages using a particular key
allows you to decrypt messages that were encrypted using this key. For example, when a shift
cipher is used with encryption key k, the plaintext integer p is sent to
c = (p + k) mod 26.
p = (c − k) mod 26.
So knowing how to encrypt with a shift cipher also tells you how to decrypt. When a private
key cryptosystem is used, two parties who wish to communicate in secret must share a secret
key. Because anyone who knows this key can both encrypt and decrypt messages, two people
who want to communicate securely need to securely exchange this key. The shift cipher and
affine cipher cryptosystems are private key cryptosystems. They are quite simple and are
extremely vulnerable to cryptanalysis. However, the same is not true of many modern private
key cryptosystems. In particular, the current US government standard for private key
cryptography, the Advanced Encryption Standard (AES), is extremely complex and is
considered to be highly resistant to cryptanalysis. AES is widely used in government and
commercial communications. However, it still shares the property that for secure
communications keys be shared. Furthermore, for extra security, a new key is used for each
communication session between two parties, which requires a method for generating keys
and securely sharing them.
To avoid the need for keys to be shared by every pair of parties that wish to communicate
securely, in the 1970s cryptologists introduced the concept of public key cryptosystems.
When such cryptosystems are used, knowing how to send an encrypted message does not
help decrypt messages. In such a system, everyone can have a publicly known encryption key.
Only the decryption keys are kept secret, and only the intended recipient of a message can
decrypt it, because, as far as it is currently known, knowledge of the encryption key does not
let someone recover the plaintext message without an extraordinary amount of work (such
as billions of years of computer time).
THE RSA CRYPTOSYSTEM
RSA (Rivest–Shamir–Adleman) is a public-key cryptosystem that is widely used for secure
data transmission. It is also one of the oldest. In 1976, three researchers at the Massachusetts
Institute of Technology—Ronald Rivest, Adi Shamir, and Leonard Adleman—introduced to
the world a public key cryptosystem, known as the RSA system, from the initials of its
inventors.
In the RSA cryptosystem, each individual has an encryption key (n, e) where n = pq, the
modulus is the product of two large primes p and q, say with 200 digits each, and an exponent
e that is relatively prime to (p − 1)(q − 1). To produce a usable key, two large primes must be
found. This can be done quickly on a computer using probabilistic primality tests, referred to
earlier in this section. However, the product of these primes n = pq, with approximately 400
digits, cannot, as far as is currently known, be factored in a reasonable length of time. As we
will see, this is an important reason why decryption cannot, as far as is currently known, be
done quickly without a separate decryption key. RSA is a relatively slow algorithm. Because
of this, it is not commonly used to directly encrypt user data. More often, RSA is used to
transmit shared keys for symmetric key cryptography, which are then used for bulk
encryption-decryption.
KEY GENERATION:
1. Choose two distinct prime numbers p and q.
2. Compute n = pq
3. Compute λ(n) = lcm(p − 1, q − 1).
4. Choose an integer e such that 1 < e < λ(n) and gcd(e, λ(n)) = 1; that is, e and λ(n) are
coprime.
5. Determine d as d ≡ e−1 (mod λ(n)); that is, d is the modular multiplicative inverse of e
modulo λ(n).
The public key consists of the modulus n and the public (or encryption) exponent e. The
private key consists of the private (or decryption) exponent d, which must be kept secret.
p, q, and λ(n) must also be kept secret because they can be used to calculate d. In fact,
they can all be discarded after d has been computed.
KEY DISTRIBUTION:
Suppose that Bob wants to send information to Alice. If they decide to use RSA, Bob must
know Alice's public key to encrypt the message and Alice must use her private key to decrypt
the message.
To enable Bob to send his encrypted messages, Alice transmits her public key (n, e) to Bob via
a reliable, but not necessarily secret, route. Alice's private key (d) is never distributed.
RSA Encryption:
After Bob obtains Alice's public key, he can send a message M to Alice. To do it, he first turns
M (strictly speaking, the un-padded plaintext) into an integer m (strictly speaking, the padded
plaintext), such that 0 ≤ m < n by using an agreed-upon reversible protocol known as a padding
scheme. He then computes the ciphertext c, using Alice's public key e, corresponding to
𝒎ⅇ ≡ 𝒄 ( 𝒎𝒐𝒅 𝒏)
This can be done reasonably quickly, even for very large numbers, using modular
exponentiation. Bob then transmits c to Alice.
Example: Encrypt the message STOP using the RSA cryptosystem with key (2537, 13). Note
that 2537 = 43 · 59, p = 43 and q = 59 are primes, and gcd(e, (p − 1)(q − 1)) = gcd(13, 42 · 58)
= 1.
To encrypt, we first translate the letters in STOP into their numerical equivalents. We then
group these numbers into blocks of four digits (because 2525 < 2537 < 252525), to obtain
1819 1415. We encrypt each block using the mapping
𝒄𝒅 ≡ (𝒎ⅇ )𝒅 ≡ 𝒎 ( 𝒎𝒐𝒅 𝒏)
Given m, she can recover the original message M by reversing the padding scheme.
Example: We receive the encrypted message 0981 0461. What is the decrypted message if it
was encrypted using the RSA cipher with key (2537, 13). Note that 2537 = 43 · 59, p = 43 and
q = 59 are primes, and gcd(e, (p − 1)(q − 1)) = gcd(13, 42 · 58) = 1
The message was encrypted using the RSA cryptosystem with n = 43 · 59 and exponent 13. As
d = 937 is an inverse of 13 modulo 42 · 58 = 2436. We use 937 as our decryption exponent.
Consequently, to decrypt a block C, we compute
0981937 mod 2537=0704 and 0461937 mod 2537=1115. Consequently, the numerical version
of the original message is 0704 1115. Translating this back to English letters, we see that the
message is HELP.
CRYPTOGRAPHIC PROTOCOLS
So far, we got to know how cryptography can be used to make messages secure. However,
there are many other important applications of cryptography. Among these applications,
there are cryptographic protocols, which are exchanges of messages carried out by two or
more parties to achieve a particular security goal. Now we will see how cryptography can be
used to allow two people to exchange a secret key over an insecure communication channel.
We will also show how cryptography can be used to send signed secret messages so that the
recipient can be sure that the message came from the purported sender.
1. KEY EXCHANGE: We now discuss a protocol that two parties can use to exchange a
secret key over an insecure communications channel without having shared any
information in the past. Generating a key that two parties can share is important for
many applications of cryptography. For example, for two people to send secure
messages to each other using a private key cryptosystem they need to share a
common key. The protocol we will describe is known as the Diffie-Hellman key
agreement protocol, after Whitfield Diffie and Martin Hellman, who described it in
1976. However, this protocol was invented in 1974 by Malcolm Williamson in secret
work at the British GCHQ. It was not until 1997 that his discovery was made public.
At the end of this protocol, Alice and Bob have computed their shared key, namely
(ak2 )k1 mod p = (ak1 )k2 mod p
To analyse the security of this protocol, note that the messages sent in steps (1), (2),
and (3) are not assumed to be sent securely. We can even assume that these
communications were in the clear and that their contents are public information. So,
p, a, ak1 mod p, and ak2 mod p are assumed to be public information. The protocol
ensures that k1, k2, and the common key (ak2 )k1 mod p = (ak1 )k2 mod p are kept secret.
To find the secret information from this public information requires that an adversary
solves instances of the discrete logarithm problem, because the adversary would need
to find k1 and k2 from ak1 mod p and ak2 mod p, respectively. Furthermore, no other
method is known for finding the shared key using just the public information. We have
remarked that this is thought to be computationally infeasible when p and a are
sufficiently large. With the computing power available now, this system is considered
unbreakable when p has more than 300 decimal digits and k1 and k2 have more than
100 decimal digits each.
2. DIGITAL SIGNATURES: Not only can cryptography be used to secure the confidentiality
of a message, but it also can be used so that the recipient of the message knows that
it came from the person they think it came from. We first show how a message can be
sent so that a recipient of the message will be sure that the message came from the
purported sender of the message. In particular, we can show how this can be
accomplished using the RSA cryptosystem to apply a digital signature to a message.
When a recipient receives her message, they apply Alice’s encryption function E(n,e) to
each block, which everyone has available because Alice’s key (n, e) is public
information. The result is the original plaintext block because E(n,e)(D(n,e)(x)) = x. So,
Alice can send her message to as many people as she wants and by signing it in this
way, every recipient can be sure it came from Alice.
ONE REAL-LIFE USE OF CRYPTOGRAPHY
Features of a secure messaging system:
So, what possible features such system should have? I will introduce a few characters in the
system. I will choose Alice, Bob, and Mallory. Alice and Bob want to exchange messages.
Mallory is evil, and he wants to listen on the conversation between Alice and Bob, and
possibly want to send messages to Alice acting as Bob and to Bob acting as Alice. We want
our system to have the following properties:
1. Confidentiality: Mallory can’t know what messages Alice and Bob send to each
other.
2. Integrity: If Bob receives a message from Alice, He can check if the message was
modified by Mallory on the way.
3. Authenticity: When Bob receives a message from Alice, He can be sure it is from
Alice and not from Mallory.
In simple words, every message that you sent to your friend, is encrypted on your device, this
encrypted message passes through network and a whole bunch of servers, reaches your
friend’s device, and finally, it is decrypted on friend’s device. So as long as underlying
cryptography is intact, you can be assured that no one else other than your friend knows
about your dirty little secret.
The Signal Protocol, designed by Open Whisper Systems, is the basis for WhatsApp’s end-to-
end encryption. This end-to-end encryption protocol is designed to prevent third parties and
WhatsApp from having plaintext access to messages or calls. What’s more, even if encryption
keys from a user’s device are ever physically compromised, they cannot be used to go back in
time to decrypt previously transmitted messages.
CONCLUSION:
In this project we can see that congruences or number theory in general is widely used in the
world of cryptography and is also very important as security is a major issue these days. As
we know cryptography ensures the integrity of data using hashing algorithms and message
digests. By providing codes and digital keys to ensure that what is received is genuine and
from the intended sender, the receiver is assured that the data received has not been
tampered with during transmission.it also assures the availability of data.
Today, in the age of computerization, we are facing increasing risk of having our intellectual
property compromised, and falling victims to cheating, fraud and impersonation. Therefore,
we need strong cryptography to protect us from these criminals. Even though we use
cryptography to convert our information into an unreadable format, needless to say, we are
still not completely safe. The criminals are becoming smarter and smarter by the day.
Advancement in technological achievements also makes them more aggressive. We can
conclude that mathematics is very important in terms of cryptography and security and one
should know about the concepts in order to protect their systems.
REFERENCE:
THEORY:
IMAGES:
• https://sectigostore.com/blog/wp-content/uploads/2020/06/how-rsa-works.png
• https://ds055uzetaobb.cloudfront.net/brioche/uploads/JO18nrj1mE-rsa-
encryption.png?width=1200
• https://thehill.com/sites/default/files/styles/article_full/public/encryption_cybersec
urity_040518istock.jpg?itok=mYvz2dXU