Introduction To Mathematical Cryptography
Introduction To Mathematical Cryptography
“Mathematical Cryptography”
◦Seminar by
1
JyothiUpadhyay
Content
● Introduction
● Simple ciphers
● Mathematics in Cryptography
● Modular Arithmetic and shift ciphers
● Types of cryptography
● Public key cryptography
● Diffie-Hellman Key exchange
● RSA Public key
● Digital signature
● Cryptography benefits and drawbacks
● References
2
Introduction
"The art of writing and solving codes"
Derived from greek word, cryptos means hidden and graphy means writing.
Internet provides essential communication between tens of millions of people and is being increasingly used as a tool
for commerce, security becomes a tremendously important issue to deal with.
There are many aspects to security and many applications, ranging from secure commerce and payments to private
communications and protecting passwords.
One essential aspect for secure communications is that of cryptography. But it is important to note that while
cryptography is necessary for secure communications, it is not by itself sufficient.
3
● Secure communication can be provided using techniques, in the presence of malicious third-party content called
adversaries. These techniques can be referred to as Cryptography.
● Any private messages can be hidden from the public or any third parties using a set of protocols. These protocols need
to be analyzed and constructed in an efficient manner in order to maintain the secrecy of message being sent.
● Modern Cryptography has a certain aspect that is central to it, like data integrity, authentication, confidentiality etc. In the
modern world, Cryptography heavily relies upon subjects like mathematics and computer science.
● Algorithms for Cryptography are designed in such a way that they are hard to crack in practice by any malicious third
party, also known as adversaries. A practical approach toward cracking such an algorithm would fail; however, the
theoretical approach may possibly crack such a system.
● Thus, any algorithm can be cited as secure if its key properties cannot be deduced with a given ciphertext. Cryptography
can be categorized into two branches: Symmetric and Asymmetric.
● Cryptography is the study of concepts like encryption, whereas encryption is a technique used to conceal messages using
algorithms.
4
Simple Ciphers
5
● In the above example we say that to encrypt
the message we used 5 letter substitution.
● Similarly to decrypt we count 5 letters
backward.
● And the “5 letter” rule is known as secret key.
● And to decrypt the message, secret key
should be known.
● But in case of this alphabetical ciphers, it's
easy to know the key just by performing some
substitutions of the letters.
● In order for decryption to work, the
encryption function must have the property
that no two plaintext letters go to the same
simple substitution cipher may be viewed as a rule or ciphertext letter. A function with this property
function is said to be one-to-one or injective.
{a,b,c,d,e,...,x,y,z} −→ {A,B,C,D,E,...,X,Y,Z}
6
2. Vigenère Cipher
Let the message be “YOU CAN TRUST ME”
Y 0 U C A N T R U S T M E Plain text
C O M P U T E R C O M P U Key (add)
B D H S V H Y J X H G C Z Cipher text
C O M P U T E R C O M P U Key (subtract)
7
Vigenère Cipher is similar to Caesar cipher. In this to encrypt the message we make use of a secret key and that secret key is a word.
To decrypt the message we make use of encrypted message and the secret key.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
A B C D E F G H I J K L M N O P Q R S T
21 22 23 24 25 26
U V W X Y Z
{a☰b(modn) / n|(a-b)}
8
In order to cipher a text, take the
first letter of the message and the
first letter of the key, add their
value (letters have a value
depending on their
rank in the alphabet, starting with
0). The result of the addition
modulo 26 (26=the number of letter
in the alphabet) gives the rank of the
ciphered letter.
9
Cryptanalysis:
The process of decrypting a message without knowing the underlying key is called cryptanalysis. (substitution ciphers) While
cryptography is the science of securing data, cryptanalysis is the science of analyzing and breaking secure communication. Classical
cryptanalysis involves an interesting combination of analytical reasoning, application of mathematical tools, pattern finding, patience,
determination, and luck. Cryptanalysts are also called attackers.
10
Mathematics in cryptography
● Much of modern cryptography is built on the foundations of algebra and number theory.
● Number Theory is the study of the natural numbers
1, 2, 3, 4, 5, 6, . . . ,
. . . ,−5,−4,−3,−2,−1, 0, 1, 2, 3, 4, 5, . . . .
● Divisibility:
Let a and b be integers with b = 0. We say that b divides a, or that a is divisible by b, if there is
an integer c such that
a=bc
11
Greatest common divisor:
A common divisor of two integers a and b is a positive integer d that divides both of them. The
greatest common divisor of a and b is, the largest positive integer d such that d | a and d | b. The
greatest common divisor of a and b is denoted gcd(a, b). If there is no possibility of confusion, it is
also sometimes denoted by (a, b).
The key to an efficient algorithm for computing greatest common divisors is division with
remainder, which is simply the method of “long division” . Thus if a and b are positive integers
and if you attempt to divide a by b, you will get a quotient q and a remainder r, where the
remainder r is smaller than b.
It is an efficient method for computing the greatest common divisor (GCD) of two integers (numbers), the largest number that
divides them both without a remainder. It is named after the ancient Greek mathematician Euclid.
It is an example of an algorithm, a step-by-step procedure for performing a calculation according to well-defined rules, and is
one of the oldest algorithms in common use.
It can be used to reduce fractions to their simplest form, and is a part of many other number-theoretic and cryptographic
calculations.
The Euclidean algorithm is based on the principle that the greatest common divisor of two numbers does not change if the
larger number is replaced by its difference with the smaller number.
If d is any common divisor of a and b, then it is clear that d is also a divisor of r. Similarly, if e is a common divisor of b and r,
then shows that e is a divisor of a. In other words, the common divisors of a and b are the same as the common divisors of b
and r; hence gcd(a, b) = gcd(b, r).
13
Ex: 2024/748, a=2024, b=748
88 = 44 · 2 + 0 −7 · 2024 + 19 · 748 = 44
gcd(2024, 748)=44
15
● Let a and b be integers. We say that a and b are relatively prime if gcd(a, b) = 1.
● The Set Of Integers Modulo P: The set:
Zp={0,1,2,...,p−1
Example: Z10={0,1,2,3,4,5,6,7,8,9,10
Modular Arithmetic :
The theory of congruences is a powerful method in number theory that is based on the simple idea of
clock arithmetic. Definition. Let n ≥ 1 be an integer. We say that the integers a and b are congruent
modulo m if their difference a − b is divisible by n. Wewrite
a ≡ b (mod n)
16
to indicate that a and b are congruent modulo n. The number n is called the modulus.
Multiplicative inverse:
A multiplicative inverse for x is a number that when multiplied by x will equal to 1 (identity). The multiplicative inverse of x is written as
x-1
and is defined as x.x-1=1
Inverse only exists if the greatest common divisor is 1 i.e., gcd(x,p)=1
Prime Number :
A prime is a number that can only be divided without a remainder by itself and 1.
For any prime number p, every number from 1 up to p−1 has a gcd of 1 with p, and therefore has a multiplicative inverse in modulo p.
17
Modular arithmetic with shift ciphers
Caesar (or shift) cipher works by shifting each letter in the alphabet a fixed number of letters. We can
describe a shift cipher mathematically by assigning a number to each letter.
Then a shift cipher with shift k takes a plaintext letter corresponding to the number p and assigns it
to the ciphertext letter corresponding to the number p + k mod 26.
The shift amount serves as both the encryption key and the decryption key. Encryption and
decryption is given by the formula
c - cipher text
p - plain text
k - secret key
18
A cryptographic algorithm, or cipher, is a mathematical function used in the encryption and decryption process.
A cryptographic algorithm works in combination with a key — a word, number, or phrase — to encrypt the plaintext.
The same plaintext encrypts to different ciphertext with different keys. The security of encrypted data is entirely dependent on
two things: the strength of the cryptographic algorithm and the secrecy of the key.
A cryptographic algorithm, plus all possible keys and all the protocols that make it work comprise a cryptosystem.
OpenPGP,RSA is a cryptosystem.
Cryptosystem:
A cryptosystem is a structure or scheme consisting of a set of algorithms that converts plaintext to ciphertext to encode or
decode messages securely. Cryptosystems are used for sending messages in a secure manner over the internet, such as credit
card information and other private data.
19
Keys
● A key is a value that works with a cryptographic algorithm to produce a specific ciphertext. Keys are basically really,
really, really big numbers. Key size is measured in bits; the number representing a 1024-bit key is really huge. In public
key cryptography, the bigger the key, the more secure the ciphertext.
● However, public key size and secret key size are totally unrelated. A private 80-bit key has the equivalent strength of a
1024-bit public key. A private 128-bit key is equivalent to a 3000-bit public key. Again, the bigger the key, the more
secure, but the algorithms used for each type of cryptography are very different and thus comparison is like that of
apples to oranges.
● While the public and private keys are mathematically related, it's very difficult to derive the private key given only the
public key; however, deriving the private key is always possible given enough time and computing power. This makes it
very important to pick keys of the right size; large enough to be secure, but small enough to be applied fairly quickly.
Additionally, you need to consider who might be trying to read your files, how determined they are, how much time
they have, and what their resources might be.
● Larger keys will be cryptographically secure for a longer period of time. If what you want to encrypt needs to be hidden
for many years, you might want to use a very large key. Keys are stored in encrypted form.
20
Symmetric and Asymmetric Key Cryptography
Cryptography is classified into symmetric key cryptography, asymmetric key cryptography.
21
Asymmetric key cryptography:
It is also known as public key cryptography because it involves usage of a public key along with secret key.
It solves the problem of key distribution as both parties uses different keys for encryption/decryption.
22
Public key Cryptography
● The problems of key distribution are solved by public key cryptography, the concept of which was introduced by Whitfield Diffie
and Martin Hellman in 1975.
● Public key cryptography is an asymmetric scheme that uses a pair of keys for encryption: a public key, which encrypts data, and
a corresponding private, or secret key for decryption. You publish your public key to the world while keeping your private key
secret. Anyone with a copy of your public key can then encrypt information that only you can read. Even people you have never
met
.
● It is computationally infeasible to deduce the private key from the public key. Anyone who has a public key can encrypt
information but cannot decrypt it. Only the person who has the corresponding private key can decrypt the information.
● The primary benefit of public key cryptography is that it allows people who have no preexisting security arrangement to
exchange messages securely.
● Some examples of public-key cryptosystems are Elgamal (named for its inventor, Taher Elgamal), RSA (named for its inventors,
Ron Rivest, Adi Shamir, and Leonard Adleman), Diffie-Hellman (named, you guessed it, for its inventors), and DSA, the Digital
Signature Algorithm (invented by David Kravitz).
● Public key encryption is the technological revolution that provides strong cryptography to the adult masses.
23
Diffie-Hellman key exchange
Key exchange:
Establishing secret key when you have to exchange it with someone over public channel.
24
Person A Person B
ga(modp)=q1
gb(modp)=q2
(gb)a(modp)=q3(secret message) =
(ga)b(modp)=q3(secret message)
25
Diffie hellman key exchange uses discrete
logarithm problem.
26
RSA Algorithm
RSA algorithm is asymmetric cryptography algorithm. Asymmetric actually means that it works on two different keys i.e. Public Key and
Private Key.
The idea of RSA is based on the fact that it is difficult to factorize a large integer. The public key consists of two numbers where one
number is multiplication of two large prime numbers. And private key is also derived from the same two prime numbers.
So if somebody can factorize the large number, the private key is compromised. Therefore encryption strength totally lies on the key
size and if we double or triple the key size, the strength of encryption increases exponentially. RSA keys can be typically 1024 or 2048
bits long.
The acronym RSA comes from the surnames of Ron Rivest, Adi Shamir and Leonard Adleman, who publicly described the algorithm in
1977.
The security of RSA relies on the practical difficulty of factoring the product of two large prime numbers, the "factoring problem".
Breaking RSA encryption is known as the RSA problem.
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.
27
RSA algorithm
1. Choose two large primes p & q
Encryption : c≡me(mod N)
Decryption : m≡cd(mod N)
2. Factor N=p*q
C - cipher text , e- public key
3. Euler’s Totient function
ɸ(n)=(p-1)(q-1) M - message , d - private key
Example:
4. Choose ‘e’ & ‘d’
e: encryption such that 1<e<ɸ(n) & coprime with 1. Choose p=2 and q=7
N, ɸ(n) 2. N=2*7=14
d: decryption 3. ɸ(n)=(p-1)(q-1)=6
e*d(modɸ(n))=1 4. e=5, d=11
5. Public key is (e,N)= (5,14)
5. Publish (e,N) as the public key 6. Private key is (d,N)= (11,14)
Let us see how to encrypt and decrypt the message using public key and private key
Encryption: 411(mod14)=4194304mod(14)
25(mod14)=32mod(14)=4 =29959.1429...mod(14)
29
Steps to follow in RSA algorithm
1. Generating the public key
2. Finding the private key
3. Encrypting the message
4. Decrypting the message.
30
Hash functions
Hashing is the process of changing a plain text or a key to a hashed value by applying a hash function. Usually, the
input length is greater in size than the output hash value.Hash function or hash algorithm creates a unique digital
fingerprint of data
The digital fingerprint of data is called digest or message digest or simply hash.
Hash algorithm are primarily used for comparison purpose not encryption.
31
Purpose of hashing:
● It is easy to keep and find records of hashed data.
● You can use hashing in cryptographic applications like a digital signature.
● Hashing can create random strings that help in avoiding data duplication.
● Geometric hashing is used in computer graphics and helps to find proximity issues in planes.
32
Digital signatures
Digital signature is equivalent to handwritten signature.
1. Authentication: a digital signature gives receiver reason to believe the message was created and sent by
claimed sender
2. Non-repudiation: with digital signature the sender can not deny having sent the message on
3. Integrity: a digital signature ensures that the message was not altered in transit.
Digital signatures are commonly used for software distribution, financial transactions and other cases where it
is important to detect the forger and tampering. Digital signatures are very popular among email users.
33
34
Applications of digital signature:
Saves time
Digital signatures ensure that businesses save on cost and time with documents and contracts signed off with a click of a button. Documents can
be signed off almost instantly, from anywhere. Be it a tablet, phone or computer, digital signatures can seamlessly ensure this otherwise tedious
Cost savings
Many companies also see significant cost savings, with little or no expense in ink, paper, printing, scanning , shipping/delivery or travel expenses.
Workflow efficiency
With lesser delays, digital signatures ensure better efficiency in workflow. Many features of digital signatures help speed up the work process. For
instance, email notifications help remind the person to sign, while status tracking, help to know at which stage the document is at.
Security
When it comes to signatures, authenticity, and security are a priority. Digital signatures reduce the risk of duplication or alteration of the
document itself. Digital signatures ensure that signatures are verified, authentic and legitimate. Signers are provided with PINs, passwords, and
codes that can authenticate and verify their identity and approve their signatures. Time stamping provides the date and time of the signature and
thus provides a track of the document, minimizing any risk of tampering or fraud. Security features embedded in digital signatures ensure that
35
Cryptography benefits and drawbacks
Benefits:
Cryptography is an essential information security tool. It provides the four most basic services of information
security −
● Confidentiality − Encryption technique can guard the information and communication from unauthorized
revelation and access of information.
● Authentication − The cryptographic techniques such as MAC and digital signatures can protect information
against spoofing and forgeries.
● Data Integrity − The cryptographic hash functions are playing vital role in assuring the users about the data
integrity.
● Non-repudiation − The digital signature provides the non-repudiation service to guard against the dispute
that may arise due to denial of passing message by the sender.
All these fundamental services offered by cryptography has enabled the conduct of business over the networks
using the computer systems in extremely efficient and effective manner.
36
Cryptography – Drawbacks
● A strongly encrypted, authentic, and digitally signed information can be difficult to access even for a
legitimate user at a crucial time of decision-making. The network or the computer system can be attacked
and rendered non-functional by an intruder.
● Cryptography comes at cost. The cost is in terms of time and money −
a. Addition of cryptographic techniques in the information processing leads to delay.
b. The use of public key cryptography requires setting up and maintenance of public key infrastructure
requiring the handsome financial budget.
● The security of cryptographic technique is based on the computational difficulty of mathematical problems.
Any breakthrough in solving such mathematical problems or increasing the computing power can render a
cryptographic technique vulnerable.
37
References
● An introduction to mathematical cryptography (2nd edition)
Jeffrey Hoffstein
Jill pipher
Joseph H.Silverman
● Numberphile
● Wikipedia
38
Thank you!!!
39