You are on page 1of 35

Applications of

Mathematics
Dr. Ramdas B.
Sonawane

Cryptography

Classical
Applications of Mathematics
Cryptography

Crytanalysis

Classical
Cryptography Dr. Ramdas B. Sonawane
The RSA Ness Wadia College of Commerce, Pune
Cryptosystem

RSA encryption

RSA Decryption

Portfolio Problem

Dr. Ramdas B. Sonawane Applications of Mathematics


Cryptography I

Applications of
Mathematics
Dr. Ramdas B. The subject of transforming information so that it
Sonawane
cannot be easily recovered without special
Cryptography
knowledge.
Classical
Cryptography Inventing cipher systems; protecting communications
Crytanalysis
and storage.
Classical
Cryptography

The RSA
Cryptosystem

RSA encryption

RSA Decryption

Portfolio Problem

Dr. Ramdas B. Sonawane Applications of Mathematics


Cryptography II

Applications of
Mathematics
Dr. Ramdas B.
Sonawane

Cryptography

Classical
Cryptography

Crytanalysis

Classical
Cryptography

The RSA
Cryptosystem

RSA encryption

RSA Decryption

Portfolio Problem

Dr. Ramdas B. Sonawane Applications of Mathematics


Classical Cryptography I

Applications of
Mathematics
Dr. Ramdas B.
Sonawane
The earliest known user of cryptography was by Julius Cae-
sar. He made messages secret by shifting each letter three
Cryptography

Classical
letters forward in the alphabet. For instance, using this
Cryptography scheme the letter B is sent to E and the letter X is sent to
Crytanalysis
A. This is an example of encryption, that is, the process of
Classical
Cryptography making a message secret.
The RSA Caesars encryption method can be represented by the func-
Cryptosystem

RSA encryption
tion f that assigns to the nonnegative integer p, p 25,
RSA Decryption the integer f (p) in the set {0, 1, 2, , 25} with
Portfolio Problem
f (p) = (p + 3) mod 26.

Dr. Ramdas B. Sonawane Applications of Mathematics


Classical Cryptography II

Applications of
Mathematics
Dr. Ramdas B.
Sonawane

Cryptography

Classical
Cryptography In the encrypted version of the message, the letter repre-
Crytanalysis
sented by p is replaced with the letter represented by (p + 3)
Classical
Cryptography mod 26.
The RSA
Cryptosystem

RSA encryption

RSA Decryption

Portfolio Problem

Dr. Ramdas B. Sonawane Applications of Mathematics


Classical Cryptography III

Applications of
Mathematics Example 1.
Dr. Ramdas B.
Sonawane What is the secret message produced from the message
Cryptography
MEET YOU IN THE PARK using the Caesar cipher?
Classical
Cryptography solution
Crytanalysis
First replace the letters in the message with numbers. This
Classical
Cryptography produces
The RSA 12 4 4 19 24 14 20 8 13 19 7 4 15 0 17 10.
Cryptosystem

RSA encryption
Now replace each of these numbers p by f (p) = (p + 3)
RSA Decryption
mod 26. This gives
Portfolio Problem 15 7 7 22 1 17 23 11 16 22 10 7 18 3 20 13.
Translating this back to letters produces the encrypted mes-
sage PHHW BRX LQ WKH SDUN.
Dr. Ramdas B. Sonawane Applications of Mathematics
Classical Cryptography IV

Applications of
Mathematics
To recover the original message from a secret message en-
Dr. Ramdas B.
Sonawane crypted by the Caesar cipher, the function f 1 , the inverse
Cryptography of f , is used.
Classical Note that the function f 1 sends an integer p from Z26 , to
f 1 (p) = (p 3) mod 26.
Cryptography

Crytanalysis

Classical
i.e. to find the original message, each letter is shifted back
Cryptography
three letters in the alphabet, with the first three letters sent
The RSA
Cryptosystem to the last three letters of the alphabet.
RSA encryption The process of determining the original message from the
RSA Decryption encrypted message is called decryption.
Portfolio Problem
There are various ways to generalize the Caesar cipher. For
example, instead of shifting the numerical equivalent of

Dr. Ramdas B. Sonawane Applications of Mathematics


Classical Cryptography V

Applications of
Mathematics
Dr. Ramdas B.
Sonawane
each letter by 3, we can shift the numerical equivalent of
each letter by k, so that
Cryptography

f (p) = (p + k)
Classical
Cryptography mod 26.
Crytanalysis

Classical
Cryptography
Such a cipher is called a shift cipher. Note that decryption
The RSA
can be carried out using
Cryptosystem

RSA encryption
f 1 (p) = (p k) mod 26.
RSA Decryption

Portfolio Problem
Here the integer k is called a key.

Dr. Ramdas B. Sonawane Applications of Mathematics


Classical Cryptography VI

Applications of
Mathematics
Dr. Ramdas B.
Example 2.
Sonawane
Encrypt the plaintext message STOP GLOBAL
Cryptography WARMING using the shift cipher with shift k = 11.
Classical
Cryptography

Crytanalysis
solution
Classical To encrypt the message STOP GLOBAL WARMING we
Cryptography
first translate each letter to the corresponding element of
The RSA
Cryptosystem Z26 . This produces the string
RSA encryption 18 19 14 15 6 11 14 1 0 11 22 0 17 12 8 13 6.
RSA Decryption
We now apply the shift f (p) = (p + 11) mod 26 to each
Portfolio Problem
number in this string. We obtain
3 4 25 0 17 22 25 12 11 22 7 11 2 23 19 24 17.

Dr. Ramdas B. Sonawane Applications of Mathematics


Classical Cryptography VII

Applications of
Mathematics Translating this last string back to letters, we obtain the
Dr. Ramdas B. ciphertext DEZA RWZMLW HLCXTYR.
Sonawane

Cryptography Example 3.
Classical
Cryptography
Decrypt the ciphertext message LEWLYPLUJL PZ H
Crytanalysis NYLHA ALHJOLY that was encrypted with the shift
Classical cipher with shift k = 7.
Cryptography

The RSA
Cryptosystem solution
RSA encryption To decrypt the ciphertext LEWLYPLUJL PZ H NYLHA
RSA Decryption ALHJOLY we first translate the letters back to elements
Portfolio Problem of Z26 . We obtain
11 4 22 11 24 15 11 20 9 11 15 25 7 13 24 11 7 0 0 11 7 9
14 11 24.
Dr. Ramdas B. Sonawane Applications of Mathematics
Classical Cryptography VIII

Applications of
Mathematics
Dr. Ramdas B.
Sonawane

Cryptography
Next, we shift each of these numbers by k = 7 modulo
Classical
Cryptography 26 to obtain
Crytanalysis 4 23 15 4 17 8 4 13 2 4 8 18 0 6 17 4 0 19 19 4 0 2 7 4 17.
Classical
Cryptography
Finally, we translate these numbers back to letters to obtain
The RSA the plaintext. We obtain EXPERIENCE IS A GREAT
Cryptosystem
TEACHER.
RSA encryption

RSA Decryption

Portfolio Problem

Dr. Ramdas B. Sonawane Applications of Mathematics


Crytanalysis

Applications of
Mathematics
Dr. Ramdas B.
Sonawane

Cryptography

Classical The process of recovering plaintext from ciphertext with-


Cryptography
out knowledge of both the encryption method and the key
Crytanalysis

Classical
is known as crytanalysis or breaking codes. In general,
Cryptography
cryptanalysis is a difficult process, especially when the en-
The RSA
Cryptosystem cryption method is unknown.
RSA encryption

RSA Decryption

Portfolio Problem

Dr. Ramdas B. Sonawane Applications of Mathematics


Public key cryptography I

Applications of
Mathematics
Classical shift cipher is an examples of private key cryp-
Dr. Ramdas B.
Sonawane tosystems. In a private key cryptosystem, once you know
Cryptography an encryption key, you can quickly find the decryption key.
Classical So, knowing how to encrypt messages using a particular
Cryptography
key allows you to decrypt messages that were encrypted
Crytanalysis

Classical
using this key. For example, when a shift cipher is used
Cryptography
with encryption key k, the plaintext integer p is sent to
The RSA
Cryptosystem

RSA encryption c = (p + k) mod 26.


RSA Decryption

Portfolio Problem Decryption is carried out by shifting by k; that is,

p = (c k) mod 26.
Dr. Ramdas B. Sonawane Applications of Mathematics
Public key cryptography II

Applications of
Mathematics So knowing how to encrypt with a shift cipher also tells you
Dr. Ramdas B.
Sonawane
how to decrypt.
When a private key cryptosystem is used, two parties who
Cryptography
wish to communicate in secret must share a secret key.
Classical
Cryptography Because anyone who knows this key can both encrypt and
Crytanalysis decrypt messages, two people who want to communicate
Classical
Cryptography securely need to securely exchange this key.
The RSA To avoid the need for keys to be shared by every pair of
Cryptosystem

RSA encryption
parties that wish to communicate securely, in the 1970s
RSA Decryption
cryptologists introduced the concept of public key cryp-
Portfolio Problem tosystems.
In public key cryptography, knowing how to encrypt does
not also tell someone how to decrypt. The most widely
Dr. Ramdas B. Sonawane Applications of Mathematics
Public key cryptography III

Applications of
Mathematics
Dr. Ramdas B.
Sonawane

Cryptography

Classical
Cryptography used public key system, called the RSA cryptosystem, en-
Crytanalysis crypts messages using modular exponentiation, where the
Classical
Cryptography modulus is the product of two large primes.
The RSA
Cryptosystem

RSA encryption

RSA Decryption

Portfolio Problem

Dr. Ramdas B. Sonawane Applications of Mathematics


The RSA Cryptosystem I

Applications of
Mathematics In 1976, three researchers at the Massachusetts Institute of
Dr. Ramdas B.
Sonawane Technology - Ronald Rivest, Adi Shamir, and LeonardAdle-
Cryptography
man -introduced to the world a public key cryptosystem,
Classical
known as the RSA system, from the initials of its inventors.
Cryptography
In the RSA cryptosystem, each individual has an encryp-
Crytanalysis
tion key (n, e) where n = pq, the modulus is the product
Classical
Cryptography of two large primes p and q, say with 200 digits each, and
The RSA
Cryptosystem
an exponent e that is relatively prime to (p 1)(q 1). To
RSA encryption produce a usable key, two large primes must be found. This
RSA Decryption can be done quickly on a computer using probabilistic pri-
Portfolio Problem mality tests. 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.
Dr. Ramdas B. Sonawane Applications of Mathematics
RSA encryption I

Applications of
Mathematics To encrypt messages using a particular key (n, e), we first
Dr. Ramdas B.
Sonawane translate a plaintext message M into sequences of integers.
Cryptography
To do this, we first translate each plaintext letter into a two-
Classical
digit number, using the same translation we employed for
Cryptography
shift ciphers, with one key difference.
Crytanalysis
That is, we include an initial zero for the letters A through
Classical
Cryptography J, so that A is translated into 00, B into 01,... , and J into
The RSA
Cryptosystem
09.
RSA encryption Then, we concatenate these two-digit numbers into strings
RSA Decryption of digits.
Portfolio Problem Next, we divide this string into equally sized blocks of 2N
digits, where 2N is the largest even number such that the
number 2525... 25 with 2N digits does not exceed n.
Dr. Ramdas B. Sonawane Applications of Mathematics
RSA encryption II

Applications of
Mathematics
Dr. Ramdas B.
Sonawane
we translate the plaintext message M into a sequence of
Cryptography integers m1, m2, , mk for some integer k. Encryption
Classical
Cryptography
proceeds by transforming each block mi to a ciphertext
Crytanalysis block ci . This is done using the function
Classical

C = Me
Cryptography
mod n.
The RSA
Cryptosystem

RSA encryption We leave the encrypted message as blocks of numbers and


RSA Decryption
send these to the intended recipient.
Portfolio Problem

Dr. Ramdas B. Sonawane Applications of Mathematics


RSA encryption III

Applications of
Mathematics
Dr. Ramdas B.
Example 4.
Sonawane
Encrypt the message STOP using the RSA cryptosystem
Cryptography
with key (2537, 13). Note that 2537 = 43 59, p = 43
Classical
Cryptography and q = 59 are primes, and
Crytanalysis

Classical gcd(e, (p 1)(q 1)) = gcd(13, 42 58) = 1.


Cryptography

The RSA
Cryptosystem solution To encrypt, we first translate the letters in STOP
RSA encryption into their numerical equivalents. We then group these num-
RSA Decryption bers into blocks of four digits (because 2525 < 2537 <
Portfolio Problem
252525), to obtain
1819 1415.

Dr. Ramdas B. Sonawane Applications of Mathematics


RSA encryption IV

Applications of
Mathematics
Dr. Ramdas B.
Sonawane

Cryptography We encrypt each block using the mapping


Classical

C = M 13
Cryptography
mod 2537.
Crytanalysis

Classical
Cryptography Computations using fast modular multiplication show that
The RSA
Cryptosystem
181913 mod 2537 = 2081 and 141513 mod 2537 = 2182.
RSA encryption The encrypted message is 2081 2182.
RSA Decryption

Portfolio Problem

Dr. Ramdas B. Sonawane Applications of Mathematics


RSA Decryption I

Applications of
Mathematics
Dr. Ramdas B. The plaintext message can be quickly recovered from a
Sonawane
ciphertext message when the decryption key d, an inverse
Cryptography of e modulo (p 1)(q 1), is known. [Such an inverse
Classical
Cryptography
exists because gcd(e, (p 1)(q 1)) = 1.] To see this, note
Crytanalysis that if de = 1( mod (p 1)(q 1)), there is an integer k
Classical such that de = 1 + k(p 1)(q 1). It follows that
Cryptography

The RSA
Cryptosystem C d = (M e )d = M de = M 1+k(p1)(q1) ( mod n).
RSA encryption

RSA Decryption By Fermats little theorem [assuming that gcd(M, p) =


Portfolio Problem
gcd(M, q) = 1, it follows that M p1 = 1( mod p) and
M q1 = 1( mod q). Consequently,

Dr. Ramdas B. Sonawane Applications of Mathematics


RSA Decryption II

Applications of
Mathematics
Dr. Ramdas B.
C d = M (M p1 ) k(q1) = M 1 = M( mod p)
Sonawane
and
Cryptography

Classical
Cryptography
C d = M (M q1 ) k(p1) = M 1 = M( mod q).
Crytanalysis
Because gcd(p, q) = 1, it follows by the Chinese remainder
Classical
Cryptography theorem that
The RSA
Cryptosystem
C d = M( mod pq).
RSA encryption

RSA Decryption
Example 5.
Portfolio Problem We receive the encrypted message 0981 0461. What is the
decrypted message if it was encrypted using the RSA
cipher from previous Example 4?
Dr. Ramdas B. Sonawane Applications of Mathematics
RSA Decryption III

Applications of
Mathematics
solution
Dr. Ramdas B.
Sonawane The message was encrypted using the RSA cryptosystem
Cryptography with n = 43 59 and exponent 13. d = 937 is an inverse of
Classical 13 modulo 42 58 = 2436.
Cryptography

Crytanalysis
We use 937 as our decryption exponent. Consequently, to
Classical decrypt a block C, we compute M = C 937 mod 2537.
Cryptography
To decrypt the message, we use the fast modular exponentia-
tion algorithm to compute 0981937 mod 2537 = 0704 and
The RSA
Cryptosystem

RSA encryption 0461937 mod 2537 = 1115. Consequently, the numerical


RSA Decryption
version of the original message is 0704 1115. Translat-
Portfolio Problem
ing this back to English letters, we see that the message is
HELP.

Dr. Ramdas B. Sonawane Applications of Mathematics


Portfolio Problem I

Applications of
Mathematics Suppose a person has some wealth. He wants to invest it
Dr. Ramdas B.
Sonawane and earn. There are many ways, he do it. He can invest
Cryptography
it in real estate, can purchase gold, can deposit in banks,
Classical
invest in stock market etc. He can gain highest returns from
Cryptography
stock market. There are many kinds of information that
Crytanalysis
might be used to predict the performance of stocks: general
Classical
Cryptography economic conditions, health of industry which the stock
The RSA
Cryptosystem
represents, productivity of the company as reflected in its
RSA encryption annual report, success of the companys competitors, and so
RSA Decryption on. Here we will study the approach using stock quotations
Portfolio Problem and some statistics to define and estimate average rate of
return on investment and the risk of investment. We use
the technique of Lagrange multipliers to put together an
Dr. Ramdas B. Sonawane Applications of Mathematics
Portfolio Problem II

Applications of
Mathematics
Dr. Ramdas B.
optimal portfolio to investment. The problem of choosing
Sonawane an optimal combination of investments is known as the
Cryptography Portfolio Problem.
Classical Suppose that we are following four possible investments,
Cryptography

Crytanalysis
whose market prices per share today are P1, P2, P3 and P4 .
Classical Let the prices for the same stocks tomorrow be denoted by
Cryptography
Q1, Q2, Q3 and Q4 .
The RSA
Cryptosystem The rate of return on the investment, that is the gain in value
RSA encryption per rupee paid on stock i, is
RSA Decryption

Portfolio Problem Qi Pi
Ri = .
Pi

Dr. Ramdas B. Sonawane Applications of Mathematics


Portfolio Problem III

Applications of
Mathematics
Dr. Ramdas B.
Sonawane
For example we have recorded the prices of the common
Cryptography stocks of four companies trading on the Bombay Stock Ex-
Classical
Cryptography
change. We followed the stocks over a period of seventeen
Crytanalysis trading days. The numbers in the rate of return columns are
Classical obtained by dividing the difference (current price minus
Cryptography

The RSA
previous price) by the previous price. Taking the arith-
Cryptosystem metical average of those observed rates of return gives the
RSA encryption
estimates of 1 , 2, 3 , and 4 listed in the row labeled
RSA Decryption
Mean.
Portfolio Problem

Dr. Ramdas B. Sonawane Applications of Mathematics


Portfolio Problem IV

Applications of
Mathematics
Dr. Ramdas B.
Sonawane

Cryptography

Classical
Cryptography

Crytanalysis

Classical
Cryptography

The RSA
Cryptosystem

RSA encryption

RSA Decryption

Portfolio Problem

Dr. Ramdas B. Sonawane Applications of Mathematics


Portfolio Problem V

Applications of
Mathematics
Table suggests that there is variability in the rates of return.
Dr. Ramdas B.
Sonawane Typically, risky investments which have high average rates
Cryptography of return also have high risks. If this is not the case, the in-
Classical vestors will all flock to high-reward, low-risk investments,
Cryptography

Crytanalysis
and market imbalances will occur. To increase safety, in-
Classical
vestors tend to diversify, that is, to spread their wealth
Cryptography
among several opportunities, hence constructing a collec-
The RSA
Cryptosystem tion of portfolio of investments. Suppose the investor has
RSA encryption total wealth W, then the decision to be made is what frac-
RSA Decryption tion wi of that wealth is to be devoted to investment i, for
Portfolio Problem
i = 1, 2, 3, 4. The total wealth invested in investment i is
wi W, and as the expected rate of return per rupee invested

Dr. Ramdas B. Sonawane Applications of Mathematics


Portfolio Problem VI

Applications of
Mathematics
Dr. Ramdas B.
is i , the expected return from our investment in investment
Sonawane
i is i wi W.
Cryptography Summing over all four investments, the total return expected
Classical
Cryptography
is
Crytanalysis

Classical 1 w1 W + 2 w2 W + 3 w3 W + 4 w4 W .
Cryptography

The RSA
Cryptosystem Since we invested W rupees, the rate of return for the port-
RSA encryption folio per rupee is
RSA Decryption
1 w1 W + 2 w2 W + 3 w3 W + 4 w4 W
= .
Portfolio Problem

Dr. Ramdas B. Sonawane Applications of Mathematics


Portfolio Problem VII

Applications of That is,


Mathematics

= 1 w1 + 2 w2 + 3 w3 + 4 w4 .
Dr. Ramdas B.
Sonawane

Cryptography

Classical
The variance V ar(R) = 2 of an uncertain rate of return is
Cryptography
the average squared difference between the rate of return R
Crytanalysis
and its mean . In the portfolio problem we will need to
Classical
Cryptography consider the risk or variance of the portfolios actual rate of
The RSA
Cryptosystem
return, which is
RSA encryption

RSA Decryption
Rp = R1 w1 + R2 w2 + R3 w3 + R4 w4 .
Portfolio Problem
Thus,

V ar(Rp ) = V ar(R1 w1 + R2 w2 + R3 w3 + R4 w4 ).
Dr. Ramdas B. Sonawane Applications of Mathematics
Portfolio Problem VIII

Applications of
Mathematics
That is,
Dr. Ramdas B.
Sonawane V ar(Rp ) = 12 w12 + 22 w22 + 32 w32 + 42 w42 .
Cryptography

Classical We have to maximize, a 2 , where a is a risk aversion


Cryptography

Crytanalysis
factor which measures the reluctance to take risk. For
Classical
example a = 0 means that you dont mind taking risk at
Cryptography
all, your only goal is to maximize average rate of return. If
The RSA
Cryptosystem a = 10, then an increase of one unit in risk will have to be
RSA encryption offset by an increase in 10 units of return in order to value
RSA Decryption the investment in the same way. A larger value of a means
Portfolio Problem
more worry about risk.
Now we are having the portfolio problem which is the con-
strained optimization problem.
Dr. Ramdas B. Sonawane Applications of Mathematics
Portfolio Problem IX

Applications of
Mathematics
Dr. Ramdas B.
Sonawane
Max. f (w1, w2, w3, w4 ) = 1 w1 + 2 w2 + 3 w3 + 4 w4
a(12 w12 + 22 w22 )
Cryptography

Classical
a(32 w32 + 42 w42 )
Cryptography sub. to g(w1, w2, w3, w4 ) = w1 + w2 + w3 + w4 1 = 0.
Crytanalysis

Classical
Cryptography
Using Lagranges multiplier method we get a system of
The RSA
equations in the unknowns , w1 , w2 , w3 and w4 :
Cryptosystem

RSA encryption 1 2a12 w1 = ,


RSA Decryption
2 2a22 w2 = ,
Portfolio Problem
3 2a32 w3 = ,
4 2a42 w4 = ,
w1 + w2 + w3 + w4 = 1.
Dr. Ramdas B. Sonawane Applications of Mathematics
Portfolio Problem X

Applications of
Mathematics From these equations we get values of w2 , w3 and w4 in
Dr. Ramdas B.
Sonawane terms of w1 as follows:
Cryptography
(2 1 )+2a12 w1
Classical w2 = 2a22
,
Cryptography
2
(3 1 )+2a1 w1
Crytanalysis w3 = 2a32
,
Classical
2
(4 1 )+2a1 w1
w4 = .
Cryptography

The RSA 2a42


Cryptosystem

RSA encryption
Thus
RSA Decryption (2 1 ) (3 1 ) (4 1 )
1
2a 2 2a 2 2a 2
Portfolio Problem
w1 = 2
2 2
3
2
4
.
1+ 2 + 2 + 2
1 1 1

2 3 4

Dr. Ramdas B. Sonawane Applications of Mathematics


Portfolio Problem XI

Applications of
Mathematics
Similarly we get values of w2 , w3 and w4 . Numerical
Dr. Ramdas B.
Sonawane computations for several values of risk aversion a and mean
Cryptography and variances from table 1, results in the following solution:
Classical
Cryptography

Crytanalysis

Classical
Cryptography

The RSA
Cryptosystem

RSA encryption

RSA Decryption

Portfolio Problem

Dr. Ramdas B. Sonawane Applications of Mathematics


Applications of
Mathematics
Dr. Ramdas B.
Sonawane

Cryptography

Classical
Cryptography

Crytanalysis

Classical
Cryptography
Thank You
The RSA
Cryptosystem

RSA encryption

RSA Decryption

Portfolio Problem

Dr. Ramdas B. Sonawane Applications of Mathematics

You might also like