PowerPoint

advertisement
The Mathematics of Star
Trek
Lecture 9: Cryptography
1
Topics





Introduction
Definitions and Terminology
Steganography
Transposition Ciphers
Substitution Ciphers
2
Introduction




Throughout history, people have had the need to
send messages to other people in secret!
Methods have been developed to disguise and break
secret messages.
Just like an organism, these methods evolve, with
new ones being developed as old ones are broken!
(Think of bacteria and antibiotics!)
More than ever the world relies on secure
transmission of data to run smoothly (email, phone,
cable TV, internet, online shopping, banking, military
communication, law enforcement, intelligence
gathering, etc.).
3
Introduction (cont.)


In this section we will look at some of the
mathematics related to cryptography,
codes and ciphers!
Let’s start with some terminology.
4
Definitions and Terminology


A code is a form of secret
communication in which a word or
phrase is replaced with a word, number,
or symbol.
Example 1: A simple code for an army.
• “Attack at dawn”  Jupiter.
• “The coast is clear”  Tippy-toe.
• Each commander and soldier would have a
copy of the codes in some sort of codebook.
5
Definitions and Terminology (cont.)






A cipher is a form of secret communication in which
letters are replaced with a letter, number, or symbol.
Example 2: One example of a cipher is to replace each
letter using the following scheme:
Plaintext
a
b
c
d
e
f
g
h
Ciphertext
Z
Y
X
W
V
U
T S
i
j
R Q
k
l
m n
o p
q r
s
t
u
v
w
x
y
z
P
O
N
L K
J
H
G
F E
D
C
B
A
M
I
Plaintext:
“attack at dawn”
Ciphertext:
“ZGGZXP ZG WZDM
Send ciphertext as ZGG ZXP ZGW ZDM.
Recipient would need to know how message was
created.
6
Definitions and Terminology (cont.)





Cryptography is the science of concealing the meaning of
a message. It is also used to mean the science of
anything connected with ciphers—an alternative to
cryptology, which is the science of secret writing.
To encrypt a message, one conceals the meaning of the
message via a code or cipher.
Similar definitions hold for encode and encipher.
To decrypt a message, one turns an ecrypted message
back into the original message.
Similar definitions hold for decode and decipher.
7
Definitions and Terminology (cont.)

Remark: The words “cryptography” and
“cryptology” come from the Greek words
•
•
•
 (kryptos)  “hidden”
 (logos)  “word” or “reason”
 (graphia) “writing”
8
Definitions and Terminology (cont.)


Steganography is the science of hiding
the existence of a message.
“Steganography” also comes from
Greek:
•

 (steganos) “covered”
Both steganography and cryptography
were developed in parallel—examples of
both have been found in the 5th century
B.C.
9
Examples of Steganography

Invisible ink (1st century A.D. – present):
•
•

Use organic fluid such as lemon juice or milk to write a
message on paper.
Heat the paper and the writing will turn brown.
Hard-boiled eggs (16th century Italy):
•
•
•
Mix alum and vinegar to make ink.
Write on hard-boiled egg.
Writing will penetrate shell and leave message on
hardened egg white surface!
10
Examples of Steganography (cont.)

Square grid (grille) method (16th
century Italy – 20th century)
•
•
•
•
•
•
Invented by Girolamo Cardano.
Text is placed on a grid.
Add in random letters to fill grid.
To read message, put cover with
correct openings onto the grid.
Variant: Use words instead of
letters and add in random words
to fill in grid.
See Edgar Allen Poe’s article “A
Few Words on Secret Writing’,
Graham’s Magazine, July 1841,
pp. 33-38.
m
e
s
s
a
g
e
r
c
m
e
w
s
t
o
s
k
p
a
b
g
e
a
r
c
m
e
w
s
t
o
s
k
p
a
b
g
e
a
11
Examples of Steganography (cont.)

Computer files (20th century – present)
•
•
•
•
•

Add data to a file, such as a JPEG image (picture).
Send via email or post to the internet on a web page.
Message undetectable without appropriate software.
Related idea: Watermarking is the addition of identifying
information into items such as checks.
Digital watermarking is used to embed copyright information
into video, music, and text data.
Note: Steganography is a great way to send a message
in secret—provided it is not found—then anyone can read
the message!
12
Cryptography!



Cryptography can be split into two
branches—transposition ciphers and
substitution ciphers.
A transposition cipher is a system of
encryption in which the letters in a message
are rearranged.
A substitution cipher is a system of
encryption in which letters in a message are
replaced with other letters or symbols.
13
Examples of Transposition Ciphers





Scytale (“SITalee) (Sparta –
5th century B.C.)
Sender and receiver have
batons of equal
circumference.
Wrap a strip of leather
around baton and write
message along length of the
baton.
Unroll the strip and carry!
Question: How would one
decipher an intercepted
scytale message?
14
Examples of Transposition Ciphers
(cont.)

Turning Grille Method (Variant of Cardano’s
method above—used by German intelligence
in South America in WWII).
•
•
•
Put text in an 8 x 8 grid, with 16 openings cut in an
overlay grid.
When rotated 90o, 180o, 270o, all 64 spaces will be
exposed exactly once.
Example from article by Stephen Fratini, Mathematics
Magazine, Volume 75, #5, December 2002, pp. 389391 (Handout).
15
Examples of Substitution Ciphers

Caesar Cipher (1st Century B.C. – used by
Julius Caesar to encrypt letters sent to Cicero).
•
•
Basic Idea: The cipher alphabet is the plain alphabet
shifted n spaces right.
For example, if we take n = 14, we get:
Plaintext
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Ciphertext
O
P
Q
R
S
T
U
V
W
X
Y
Z
A
B
C
D
E
F
G
H
I
J
K
L
M N
•
•
Plaintext:
Ciphertext:
“attack at dawn”
“OHHOQY OH ROKB”
16
z
Examples of Substitution Ciphers
(cont.)

Keyword Cipher
• Use a keyword or phrase as the basis of the
•
•
•
encryption scheme.
For example, let MATHEMATICS be the
keyword.
Remove repeated letters in the keyword and
add in remaining letters of alphabet in order.
MATHEMATICS  MATHEICS
Plaintext
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Ciphertext
M
A
T
H
E
I
C
S
B
D
F
G
J
K
L
N
O
P
Q
R
U
V
W
X
Y
Z
17
Examples of Substitution Ciphers
(cont.)

Rearrangement Cipher
• Rearrange letters of alphabet in any order.
• The Caesar and keyword ciphers are special
•
•
cases of the rearrangement cipher!
Question: How many different rearrangement
ciphers are there?
To answer this question, we need the
Fundamental Principle of Counting!
18
Examples of Substitution Ciphers
(cont.)

Fundamental Principle of Counting
(FPC):
• If there are
n1 choices for item 1
n2 choices for item 2
…
nm choices for item m
then the number of ways to choose one of
each item is n1 x n2 x ... x nm.
19
Examples of Substitution Ciphers
(cont.)

Example 3: How many outfits can I
make with 4 shirts, 3 pairs of pants, and
5 pairs of shoes?
• # shirt choices: 4
• # pants choices: 3
• # shoe choices: 5
• FPC implies 4 x 3 x 5 = 60 outfits
20
Examples of Substitution Ciphers
(cont.)

To figure out how many different
rearrangement ciphers there are, we can use
FPC:
•
•
•
•
•
•
# choices for ciphertext letter for a:
26
# choices for ciphertext letter for b:
25
…
# choices for ciphertext letter for y:
2
# choices for ciphertext letter for z:
1
FPC implies 26 x 25 x … x 2 x 1 = 26!, or about
4.03 x 1026 different ciphers!
21
Examples of Substitution Ciphers
(cont.)



Additive Cipher
•
Using the idea of modular arithmetic, we can create a cipher!
For any non-negative integer a and positive integer n, we
define a mod n to be the remainder when a is divided by n.
Example 4:
18 mod 5 = 3, since 18 = 3 x 5 + 3
4 mod 7 = 4, since 4 = 0 x 7 + 4
28 mod 26 = 2, since 28 = 1 x 26 + 2
26 mod 13 = 0, since 26 = 2 x 13 + 0
22
Examples of Substitution Ciphers
(cont.)


We can add and multiply numbers mod n too!
Example 5: Find (27+15) mod 26 and (27x15) mod 26.
•
•
27+15 = 42 and 42 mod 26 = 16,
so (27+15) mod 26 = 16
or
27 mod 26 = 1 and 15 mod 26 = 15,
so (27+15) mod 26 = (1+15) mod 26 = 16 mod 26 = 16
27 x 15 = 405 and 405 mod 26 = 15,
so (27 x 15) mod 26 = 15
or
(27 x 15) mod 26 = (1 x 15) mod 26 = 15 mod 26 = 15
23
Examples of Substitution Ciphers
(cont.)

To find (a+b) mod n:
• Add a to b, then find the resulting sum mod n,
• Or find a mod n, find b mod n, and add the
•


results mod n.
Multiplication works in a similar fashion!
Handout: + and x tables for Zn
Now we are ready to make an additive
cipher!
24
Examples of Substitution Ciphers
(cont.)




First, assign 1, 2, …, 26 mod 26 to a, b, …, z.
Next, choose a fixed integer m between 0 and 25.
To get the ciphertext y from plaintext x, add m mod 26, i.e., y =
(x+m) mod 26.
As an example, here is the additive cipher alphabet for m=14.
Plaintext
a
b
c
d
e
f
g
h
i
j
k
l
m
Plaintext #
1
2
3
4
5
6
7
8
9
10
11
12
13
Ciphertext #
15
16
17
18
19
20
21
22
23
24
25
0
1
Ciphertext
O
P
Q
R
S
T
U
V
W
X
Y
Z
A
Plaintext
n
o
p
q
r
s
t
u
v
w
x
y
z
Plaintext #
14
15
16
17
18
19
20
21
22
23
24
25
0
Ciphertext #
2
3
4
5
6
7
8
9
10
11
12
13
14
Ciphertext
B
C
D
E
F
G
H
I
J
K
L
M
N
25
Examples of Substitution Ciphers
(cont.)

Continuing the additive cipher example
with m = 14, to encipher the plaintext
letter e, we do the following:
•e5
• (5+14) mod 26 = 19 mod 26 = 19
• 19  S
• Thus, plaintext e is enciphered as ciphertext S.
26
Examples of Substitution Ciphers
(cont.)

Continuing the additive cipher example with m = 14, to
decipher ciphertext S, we add the additive inverse of 14
mod 26, which is 12:
•
•
•
•


S  19
(19+12) mod 26 = 31 mod 26 = 5
5e
Thus, ciphertext S is deciphered as plaintext e.
Question: What does the additive cipher look like?
Answer: Caesar cipher! (The Caesar cipher is also
called the additive cipher!)
27
Notes on Ciphers


For any cipher there is an algorithm,
which is a general encrypting method,
and a key which specifies the exact
details of the algorithm.
Example 6: For the Caesar cipher,
• Algorithm—shift the alphabet,
• Key—how many places to shift!
• Thus, there are 26 keys for this cipher.
28
Notes on Ciphers (cont.)

The key must remain secure!
• If the key is found, the code will be broken.
• If the algorithm is known, the code can still be
•
secure!
For a code or cipher, the greater the number
of keys, the greater the security!
29
Notes on Ciphers (cont.)


The examples of substitution ciphers
we’ve seen are called monoalphabetic
substitution ciphers.
The systems we’ve seen are symmetric
because sender and receiver must both
know (have) the key.
30
References



The Code Book by Simon Singh, Anchor Books,
1999.
Stephen Fratini, “An Encryption Algorithm using a
Variation of the Turning-Grille Method”, Mathematics
Magazine, Volume 75, Number 5, December 2002,
pp. 389-391.
Edgar Allen Poe, “A Few Words on Secret Writing”,
Graham’s Magazine, July 1841, pp. 33-38.
31
Download