Upload
others
View
1
Download
0
Embed Size (px)
Citation preview
Skills for Mathematical Sciences - Cryptographyand Factorisation
Dr Craig
3 February 2017
What is cryptography?
The science of protecting information bytransforming it (encrypting it) into an unreadableformat, called ciphertext.
Plaintext is normal text which can be read byanyone. Plaintext is encrypted into ciphertext whichcan then be decrypted back into plaintext.
A cipher is the method used to encrypt anddecrypt the plaintext.
Where is cryptography used?
In 50BC:
Julius Caesar, the Roman emperor, used
encrypted messages to communicate with his
generals.
Where is cryptography used?
In World War II:
Where is cryptography used?
I internet bankingI cellphone calls and messagesI online transactionsI military and diplomatic communication
A simple cipher: the Caesar cipher
Choose any number x. Shift each letter x
places along the alphabet.
Example: x = 5:
a −→ f
b −→ g
. . .
y −→ d
z −→ e
Grahamstown −→ Lwfmfrxytbs
Using maths: how secure is your cipher?
Q: What is the problem with the Caesar
cipher?
A: Once you know the encryption of one
letter, you know the encryption of them all.
Q: How many possible Caesar ciphers are
there?
A: 26
We can break a Caesar cipher by trying all 26
possible combinations. A bit of hard work,
but not too bad (especially for a computer).
Making stronger ciphers: What if we no longerrequire that the substitution simply shifts the orderof the alphabet? That is, we could have asubstitution that looks as follows:
a −→ p
b −→ a
c −→ n
. . .
y −→ m
z −→ q
How many different substitution ciphers like thisexist? 26× 25× 24× . . .× 3× 2× 1 =
403, 291, 461, 126, 605, 635, 584, 000, 000
How to break a cipher: frequency analysis
Frequency analysis uses the fact that certain lettersoccur more often than others. The technique wasfirst developed in the 9th century by Al Kindi, anArab mathematician and philosopher.
In English, the letters that occur most often are:
E T A O I N
% 12.7 9.1 8.2 7.5 7.0 6.7
More tricks for frequency analysis:Digrams are pairs of letters which occur
together. The most common digrams are:
TH HE IN ER AN RE ED
We can look for common pairs of letters in
the ciphertext and match them to the most
common digrams.
We also know which letters are repeated
most often:
SS, EE, TT, FF, LL, MM and OO.
Frequency in English:
Frequency in Text 1:
Frequency in Text 2:
Ciphertext 1:
KA, JRA GAXGEA XD NXOJR IDHYPI, HAPXZFYNA JRA
YFBONJYPAN XD XOH GINJ; RXFXOH JRXNA KRX NODDAHAC
DXH BONJYPA IFC DHAACXU YF XOH EIFC; HANGAPJ
JRXNA KRX RITA KXHQAC JX MOYEC IFC CATAEXG XOH
PXOFJHV; IFC MAEYATA JRIJ NXOJR IDHYPI MAEXFZN JX
IEE KRX EYTA YF YJ, OFYJAC YF XOH CYTAHNYJV.
Ciphertext 2:
DS KSGU ABJGZCGR BXX UDS RNBJGW QI UDBJRD UDSNS
KSNS NBZVSUI CG DCI UBSI QGW SQZD IUNCWS DS UBBV
FCXUSW DCT CGUB UDS QCN. DS DQWGU SMSG RBGS CGUB
UDQU KDCPPCGR UBY RSQN BX DCI, KDSG UDS RNBJGW
ASZQTS AFJNNSW QGW UDS KCGW DBKFSW QGW DCI XSSU
WCWGU ISST UB AS UBJZDCGR QGLUDCGR AJU QCN.
Ciphertext 1:
KE, JRE GEXGEE XD NXOJR IDHYPI, HEPXZFYNE JRE
YFBONJYPEN XD XOH GINJ; RXFXOH JRXNE KRX NODDEHEC
DXH BONJYPE IFC DHEECXU YF XOH EIFC; HENGEPJ
JRXNE KRX RITE KXHQEC JX MOYEC IFC CETEEXG XOH
PXOFJHV; IFC MEEYETE JRIJ NXOJR IDHYPI MEEXFZN JX
IEE KRX EYTE YF YJ, OFYJEC YF XOH CYTEHNYJV.
Ciphertext 2:
DE KEGU ABJGZCGR BXX UDE RNBJGW QI UDBJRD UDENE
KENE NBZVEUI CG DCI UBEI QGW EQZD IUNCWE DE UBBV
FCXUEW DCT CGUB UDE QCN. DE DQWGU EMEG RBGE CGUB
UDQU KDCPPCGR UBY REQN BX DCI, KDEG UDE RNBJGW
AEZQTE AFJNNEW QGW UDE KCGW DBKFEW QGW DCI XEEU
WCWGU IEET UB AE UBJZDCGR QGLUDCGR AJU QCN.
Text 1:
We, the people of South Africa,Recognise the injustices of our past;Honour those who suffered for justice and freedom in our land;Respect those who have worked to build and develop ourcountry; andBelieve that South Africa belongs to all who live in it, unitedin our diversity.
Text 2:
He went bouncing off the ground as though there were rocketsin his toes and each stride he took lifted him into the air.He hadn’t even gone into that whizzing top gear of his, whenthe ground became blurred and the wind howled and his feetdidn’t seem to be touching anything but air.
Prime time
Given an integer n (that is, n ∈ Z) we say
that a ∈ Z is a factor of n if there exists
b ∈ Z such that a · b = n.
A positive integer p that is greater than 1 is
said to be prime if it has exactly two
factors: 1 and p.
The largest known prime number was
discovered in 2016. It has 22,338,618 digits!
It is a Mersenne prime, so it is easy to write:
274,207,281 − 1
Fundamental Theorem ofArithmetic: every integer n > 1 can be
written uniquely as the product of powers
of its prime factors. That is, if n has m
different prime factors, then
n = pk11 · pk22 · · · pkmm
What is the easiest/most efficient way to
factorise a number into its prime factors?
Relatively prime
Two positive integers are said to be
relatively prime if their greatest common
divisor is 1. That is, they share no common
factors other than 1. Examples are:
I 12 and 5
I 33 and 35
I 15 and 154
Exercise: find out how many numbers below
16 are relatively prime to 16. Do the same
for 18.
Euler’s Phi Function
Discoverd by Leonard Euler in 1763. If
n = pk11 · pk22 · · · pkmm
then
ϕ(n) = n
(p1 − 1
p1
)(p2 − 1
p2
)· · ·
(pm − 1
pm
)What about ϕ(n) when n = p · q for p, q
prime? Then
ϕ(n) = (p− 1)(q − 1)
Multiplying versus factorising
It is worth watching this entire video. If you
just want to see the difference in complexity
between multiplication and factorisation,
watch from 6:30 to 8:15.
https://www.youtube.com/watch?v=wXB-V_Keiu8
The main point here is that it is
computationally easy to multiply two large
numbers but very difficult to factorise a large
number.
Using prime numbers in cryptography
A very general description of RSA encryption:I Take two large prime numbers p and q. Multiply
them to get n = p× q.I Calculate ϕ(n) (easy if you know p and q!).I Choose e such that e is relatively prime to ϕ(n)
and 1 6 e 6 ϕ(n).I Make n and e public. Your counterparts will use
these to encode their messages.I Calculate d (the multiplicative inverse of emod ϕ(n), i.e. d · e = 1 + kϕ(n), k ∈ Z). NB:you can’t quickly find d without knowing ϕ(n).
I After receiving a message encrypted with n ande, you will decode it using d and ϕ(n).
More about prime numbers
Become a GIMP!
Remember the largest prime with 22 million
digits? This was found by GIMPS – Great
Internet Mersenne Prime Search. This search
method uses the computing power of idle
computers to search for prime numbers. You
can find out more and sign up for GIMPS
here:
http://www.mersenne.org/
The Goldbach Conjecture
“Every even positive integer greater than 2
can be written as the sum of two primes.”
No proof of this has yet been found but all of
the even numbers up to
4× 1017
have been checked and the conjecture holds
for all of them.
The twin prime conjecture
The pairs 17, 19 and 29, 31 are examples of
twin primes. The conjecture states:
“There are infinitely many pairs of twin
primes.”
Read this article for coverage of the progress
towards resolving the conjecture: http://www.
slate.com/articles/health_and_science/do_the_
math/2013/05/yitang_zhang_twin_primes_conjecture_
a_huge_discovery_about_prime_numbers.html