1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.
-
Upload
bryan-wilkinson -
Category
Documents
-
view
218 -
download
1
Transcript of 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.
![Page 1: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/1.jpg)
1
Codes, Ciphers, and Cryptography-Ch 3.1
Michael A. Karls
Ball State University
![Page 2: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/2.jpg)
2
Substitution and Permutation Ciphers In Chapter 1 we looked at various
examples of monoalphabetc substitution ciphers.
A convenient way to describe these ciphers is via permutations!
![Page 3: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/3.jpg)
3
Functions
A function f is a rule that assigns to each element x in a set A exactly one element, called f(x), in a set B.
Notation: f: A B; y = f(x)
A B
xf(x)
f
![Page 4: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/4.jpg)
4
One-to-One Function
We say a function f: AB is one-to-one (1-1) if f(x1) f(x2) whenever x1 x2.
1
4
5
0
365
A B
f
f is 1-1
![Page 5: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/5.jpg)
5
Onto Function
We say f: AB is onto if given y in B, there is an element x in A such that f(x) = y.
1
4
5
1
2
A B
g
g is onto
![Page 6: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/6.jpg)
6
“Neither” Function
Not all functions are 1-1 or onto!
1
4
5
0
1
2
A B
h
h is neither 1-1 nor onto
![Page 7: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/7.jpg)
7
Example 1: Some functions!
(a) f: AB where A = (- 1, 1), B = [0, 1), and f(x) = x2.
f(1) = 12 = 1 f(2) = 22 = 4 f(-2) = (-2)2 = 4 … f is onto, not 1-1
![Page 8: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/8.jpg)
8
Example 1: Some functions!
(b) f: AB where A = {books in library}, B = {possible call numbers}, and f is the rule “call number on book spine”.
f is 1-1, but not onto (different books have different call numbers).
![Page 9: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/9.jpg)
9
Example 1: Some functions!
(c) Permutations: Let A = Zn and B = Zn where Zn = {0, 1, 2, … , n}. Then a 1-1, onto function f: ZnZn is called a permutation.
Example: Z6 = {0, 1, 2, 3, 4, 5}. is the permutation given by the table below.
Notation: instead of (x), we use x – it will be useful later!
x 0 1 2 3 4 5
x 1 2 0 3 5 4
![Page 10: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/10.jpg)
10
Cycle Notation
We can use cycle notation to describe a permutation! A cycle is a process that repeats itself. As an example, in Example 1(c) would be written as
= (012)(3)(45), a 3-cycle, followed by a 1-cycle, followed by a 2-cycle.
Here, (012) represents the cycle 0120(3) represents the cycle 33(45) represents the cycle 454.
Notice that the cycles of are disjoint, i.e. no symbol appears in more than one cycle.
![Page 11: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/11.jpg)
11
Cycle Notation
Fact 1: Every permutation can be written as a product of disjoint cycles.
![Page 12: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/12.jpg)
12
Cycle Notation
Example 2: Write the permutation : Z6Z6 given by (01)(2453) in table form.
Solution: x (01)(2453) x
0 1 11 0 02 2 43 3 24 4 55 5 3
![Page 13: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/13.jpg)
13
Cycle Notation
Example 2 (cont.) Thus, the table form of the permutation
= (01)(2453) is given by:
x 0 1 2 3 4 5
x 1 0 4 2 5 3
![Page 14: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/14.jpg)
14
Operations on Permutations
Given two permutations : ZnZn and : ZnZn, we can form new permutations!
Given a permutation , the inverse of is the permutation -1 defined by:
x = y^(-1) if and only if y = x.
A B
x
y-1
![Page 15: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/15.jpg)
15
Operations on Permutations
Example 3: For Example 1(c), -1 is given by the table below.
Therefore, -1 = (021)(3)(45) in cycle form.
x 0 1 2 3 4 5
x^(-1) 2 0 1 3 5 4
![Page 16: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/16.jpg)
16
Operations on Permutations
Note: If is a 1-cycle or a 2-cycle, then -
1 = .
If = (x1 x2 … xn), then -1 = (x1 xn … x2). “Proof”:
For = (1234), we have 12341. For -1, we have 14321, which is (1432) in cycle notation.
![Page 17: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/17.jpg)
17
Operations on Permutations
Given permutations : ZnZn and : ZnZn, the product is the permutation obtained by applying first, then .
Notation: x = (x).
![Page 18: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/18.jpg)
18
Operations on Permutations
Example 4: Find if = (012)(3)(45) and = (01)(2453). Solution: x (012)(3)(45) x (01)(2453) (x)
0 11 1 0 01 22 2 2 42 00 0 1 13 33 3 3 24 44 5 5 35 55 4 4 5
Thus, = (0)(1432)(5) (or we could write (1432)).
![Page 19: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/19.jpg)
19
Operations on Permutations
Fact 2: The inverse of a product of permutations is given by ()-1 = -1 -1.
![Page 20: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/20.jpg)
20
Operations on Permutations
Example 5: Let and be as in the last example.
Then = (0)(1432)(5), so it follows from the Note above that ()-1 = (0)(1234)(5).
Now, -1 = (021)(3)(45) and -1 = (01)(2354), so by Fact 2,
()-1 = -1-1 = (01)(2354) (021)(3)(45). Check that we get the same result!
![Page 21: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/21.jpg)
21
Operations on Permutations
Example 5(cont.) x (01)(2354) x^(-1) (021)(3)(45) (x^(-1))^(-1)
0 1 01 0 22 3 33 5 44 2 15 4 5
Thus, -1-1= (0)(1234)(5), so()-1 = -1-1 for this example!
![Page 22: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/22.jpg)
22
Substitution Ciphers (Revisited)
By labeling the letters A, B, C, … , Y, Z as 0, 1, 2, … , 24, 25, any substitution cipher is equivalent to some permutation : Z26Z26.
Usually we just write the letters instead of the numbers!
![Page 23: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/23.jpg)
23
Substitution Ciphers (Revisited)
Example 6: Use the substitution cipher: = (APHITX)(BERC)(DNZFVM)(GJKWLOYQSU)
to encipher the plaintext “BSUMATH”. x (APHITX)(BERC)(DNZFVM)(GJKWLOYQSU) x
B B E E E
S S S S U
U U U U G
![Page 24: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/24.jpg)
24
Substitution Ciphers (Revisited)
Example 6 (cont.) x (APHITX)(BERC)(DNZFVM)(GJKWLOYQSU) x
M M M D D
A P P P P
T X X X X
H I I I I Thus, “BSUMATH” is encrypted as “EUGDPXI”.
![Page 25: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/25.jpg)
25
Permutation Ciphers
Another way to make a cipher with a permutation is to use a fixed-length permutation to rearrange blocks of text of the same length.
We illustrate this method with the next example!
![Page 26: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/26.jpg)
26
Permutation Ciphers
Example 7 (a permutation cipher) First, choose a permutation of the
numbers 1-9. For example, = (147)(238956).
Next, break up plaintext into blocks of length 9:
this is a form of a transposition cipher
![Page 27: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/27.jpg)
27
Permutation Ciphers
Example 7 (a permutation cipher) First, choose a permutation of the
numbers 1-9. For example, = (147)(238956).
Next, break up plaintext into blocks of length 9:
this is a fo|rm of a tran|sposition| cipherabc
![Page 28: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/28.jpg)
28
Permutation Ciphers
T H I S I S A F O
1 2 3 4 5 6 7 8 9
4 3 8 7 6 2 1 9 5
S I F A S H T O I
![Page 29: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/29.jpg)
29
Permutation Ciphers
R M O F A T R A N
1 2 3 4 5 6 7 8 9
4 3 8 7 6 2 1 9 5
F O A R T M R N A
![Page 30: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/30.jpg)
30
Permutation Ciphers
S P O S I T I O N
1 2 3 4 5 6 7 8 9
4 3 8 7 6 2 1 9 5
S O O I T P S N I
![Page 31: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/31.jpg)
31
Permutation Ciphers
C I P H E R A B C
1 2 3 4 5 6 7 8 9
4 3 8 7 6 2 1 9 5
H P B A R I C C E
![Page 32: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/32.jpg)
32
Permutation Ciphers
For Example 7, the ciphertext is SIFASHTOI FOARTMRNA SOOITPSNI
HPBARICCE
![Page 33: 1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.](https://reader036.fdocuments.us/reader036/viewer/2022062421/56649da85503460f94a958b4/html5/thumbnails/33.jpg)
33
Permutation Ciphers
Remark: The cipher in Example 7 is known as a stream cipher.
Such ciphers can be used for high speed encryption with computers.
Flaw: The Friedman Test can be used to guess it is a transposition cipher.