1 Codes, Ciphers, and Cryptography-Ch 2.3 Michael A. Karls Ball State University.

Slides:



Advertisements
Similar presentations
Copyright © 2010, 2007, 2004 Pearson Education, Inc. Chapter 14 From Randomness to Probability.
Advertisements

Copyright © 2006 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Chapter 6 Probability and Simulation
Basic Terms of Probability Section 3.2. Definitions Experiment: A process by which an observation or outcome is obtained. Sample Space: The set S of all.
From Randomness to Probability
Copyright © Cengage Learning. All rights reserved.
1 1 PRESENTED BY E. G. GASCON Introduction to Probability Section 7.3, 7.4, 7.5.
Chapter 7 Probability 7.1 Experiments, Sample Spaces, and Events
Probability Of An Event Dhon G. Dungca, M.Eng’g..
Math 310 Section 7.1 Probability. What is a probability? Def. In common usage, the word "probability" is used to mean the chance that a particular event.
COMP 170 L2 L16: Conditional Probability and Independence Page 1.
Information Theory and Security
Copyright © 2010, 2007, 2004 Pearson Education, Inc. Chapter 14 From Randomness to Probability.
1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.
Sets, Combinatorics, Probability, and Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProbability.
Sets, Combinatorics, Probability, and Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProbability.
Cryptanalysis of the Vigenere Cipher Using Signatures and Scrawls To break a Vigenere cipher you need to know the keyword length. – The Kasiski and Friedman.
Chapter 8 Probability Section R Review. 2 Barnett/Ziegler/Byleen Finite Mathematics 12e Review for Chapter 8 Important Terms, Symbols, Concepts  8.1.
Probability.
1 Probability. 2 Today’s plan Probability Notations Laws of probability.
From Randomness to Probability
Warm-Up 1. What is Benford’s Law?
Section 2.7: The Friedman and Kasiski Tests Practice HW (not to hand in) From Barr Text p. 1-4, 8.
Polyalphabetic CIPHERS Linguistics 484. Summary The idea How to recognize: index of coincidence How many alphabets: Kasiski.
Lesson 6 – 2b Probability Models Part II. Knowledge Objectives Explain what is meant by random phenomenon. Explain what it means to say that the idea.
Copyright © 2010 Pearson Education, Inc. Chapter 14 From Randomness to Probability.
1 CHAPTERS 14 AND 15 (Intro Stats – 3 edition) PROBABILITY, PROBABILITY RULES, AND CONDITIONAL PROBABILITY.
Applicable Mathematics “Probability” Page 113. Definitions Probability is the mathematics of chance. It tells us the relative frequency with which we.
PROBABILITY, PROBABILITY RULES, AND CONDITIONAL PROBABILITY
The Wonderful World… of Probability. When do we use Probability?
5.1 Randomness  The Language of Probability  Thinking about Randomness  The Uses of Probability 1.
From Randomness to Probability Chapter 14. Dealing with Random Phenomena A random phenomenon is a situation in which we know what outcomes could happen,
Probability Prof. Richard Beigel Math C067 September 27, 2006.
Sixth lecture Concepts of Probabilities. Random Experiment Can be repeated (theoretically) an infinite number of times Has a well-defined set of possible.
Natural Language Processing Giuseppe Attardi Introduction to Probability IP notice: some slides from: Dan Jurafsky, Jim Martin, Sandiway Fong, Dan Klein.
Conditional Probability Mass Function. Introduction P[A|B] is the probability of an event A, giving that we know that some other event B has occurred.
Probability Rules In the following sections, we will transition from looking at the probability of one event to the probability of multiple events (compound.
Basic Concepts of Probability
Introduction to Cryptography Lecture 8. Polyalphabetic Substitutions Definition: Let be different substitution ciphers. Then to encrypt the message apply.
Probability. What is probability? Probability discusses the likelihood or chance of something happening. For instance, -- the probability of it raining.
5-Minute Check on Section 6-2a Click the mouse button or press the Space Bar to display the answers. 1.If you have a choice from 6 shirts, 5 pants, 10.
Probability and Simulation The Study of Randomness.
Section 6.2: Definition of Probability. Probability of an event E denoted P(E) is the ratio of the number of outcomes favorable to E to the total number.
Copyright © 2010 Pearson Education, Inc. Chapter 14 From Randomness to Probability.
Sample Space and Events Section 2.1 An experiment: is any action, process or phenomenon whose outcome is subject to uncertainty. An outcome: is a result.
AP Statistics From Randomness to Probability Chapter 14.
Essential Ideas for The Nature of Probability
Mathematics Department
The Mathematics of Star Trek Workshop
ICS 253: Discrete Structures I
Chapter 4 Probability Concepts
Probability Imagine tossing two coins and observing whether 0, 1, or 2 heads are obtained. It would be natural to guess that each of these events occurs.
PROBABILITY AND PROBABILITY RULES
Natural Language Processing
What is Probability? Quantification of uncertainty.
Section 2.7 The Friedman and Kasiski Tests
BASIC PROBABILITY Probability – the chance of something (an event) happening # of successful outcomes # of possible outcomes All probability answers must.
From Randomness to Probability
5.1 Probability of Simple Events
Natural Language Processing
Discrete Probability Chapter 7 With Question/Answer Animations
Introduction to Probability
CSCI 5832 Natural Language Processing
PROBABILITY AND STATISTICS
Activity Gerolamo Cardano, Italian mathematician, wrote the first book about Probability in Chances Are!
Honors Statistics From Randomness to Probability
Click the mouse button or press the Space Bar to display the answers.
CHAPTER 5 Probability: What Are the Chances?
Lecture 2 Basic Concepts on Probability (Section 0.2)
A random experiment gives rise to possible outcomes, but any particular outcome is uncertain – “random”. For example, tossing a coin… we know H or T will.
Presentation transcript:

1 Codes, Ciphers, and Cryptography-Ch 2.3 Michael A. Karls Ball State University

2 The Friedman Test The Kasiski Test is a method to determine the length of a Vigenère cipher keyword via distances between repeated sequences of ciphertext. The Friedman Test, which was developed by Colonel William Friedman in 1925, uses probability to determine whether a ciphertext has been enciphered using a monoalphabetic or polyalphabetic substitution cipher. Another use of the Friedman Test is to find the length of a Vigenère cipher keyword!

3 Basic Probability Concepts Formally, the study of probability began with the posthumous publication of Girolamo Cardano’s “Book on Games and Chance” in  Probably he wrote it in ~1563.  Recall Cardano also worked with grids for encryption! Other “key” players in the development of this branch of mathematics include:  Blaise Pascal and Pierre de Fermat (17 th century).  Jakob Bernoulli (late 17 th century).

4 Definition of Probability One way to define probability is as follows:  The probability of an event E is a quantified assessment of the likelihood of E.  By quantified, we mean a number is assigned. In order to understand this definition, we need some more definitions and concepts!

5 More Definitions! Each time we consider a probability problem, we think of it as an experiment, either real or imagined.  An experiment is a test or trial of something that is repeatable. The first step in such a problem is to consider the sample space.  The sample space S of an experiment is a set whose elements are all the possible outcomes of the experiment.

6 Example 1: Some Experiments and Sample Spaces 1(a)  Experiment: Select a card from a deck of 52 cards.  Sample Space: S = {A , A, A , A , 2 , 2, 2 , 2  …, K , K, K , K  } 1(b)  Experiment: Poll a group of voters on their choice in an election with three candidates, A, B, and C.  Sample Space: S = { A, B, C}.

7 Example 1: Some Experiments and Sample Spaces (cont.) 1(c)  Experiment: Flip a coin, observe the up face.  Sample Space: S = {H, T} 1(d)  Experiment: Roll two six-sided dice, observe up faces.  Sample Space: S = {(1,1), (1,2), (1,3), (1,4), (1,5), (1,6), …, (6,1), (6,2), (6,3), (6,4), (6,5), (6,6)}

8 Another Definition! When working with probability, we also need to define event.  An event E is any subset of the sample space S. An event consists of any number of outcomes in the sample space.  Notation: E  S.

9 Example 2: Some Events 2(a)  Experiment: Select a card from a deck of 52 cards.  Sample Space: S = {A , A, A , A , 2 , 2, 2 , 2  …, K , K, K , K  }  Event: Select a card with a diamond. E = {A , 2 , …, K  }

10 Example 2: Some Events (cont.) 2(b)  Experiment: Poll a group of voters on their choice in an election with three candidates, A, B, and C.  Sample Space: S = { A, B, C}  Event: Voter chooses B or C. E = {B,C}.

11 Example 2: Some Events (cont.) 2(c)  Experiment: Flip a coin, observe the up face.  Sample Space: S = {H, T}  Event: Up face is Tail. E = {T}.

12 Example 2: Some Events (cont.) 2(d)  Experiment: Roll two six-sided dice, observe up faces.  Sample Space: S = {(1,1), (1,2), (1,3), (1,4), (1,5), (1,6), …, (6,1), (6,2), (6,3), (6,4), (6,5), (6,6)}  Event: Roll a pair: E = {(1,1}, (2,2), (3,3), (4,4), (5,5), (6,6)}

13 Example 2: Some Events (cont.) 2(e)  Experiment: Roll two six-sided dice, add the up faces.  Sample Space: S = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}  Event: Roll an odd sum: E = {3, 5, 7, 9, 11}

14 Probability of an Event With these definitions, we can now define how to compute the probability of an event!

15 How to find the Probability of an Event E 1. Determine the elements of the sample space S. S = {s 1, s 2, …, s n }. 2. Assign a weight or probability (i.e. number) to each element of S in such a way that:  Each weight is at least 0 and at most 1.  The sum of all the weights is 1.  (For each element s i in S, denote its weight by p(s i ).) 3. Add the weights of all outcomes contained in event E. 4. The sum of the weights of E is the probability of E and is denoted p(E).

16 How to find the Probability of an Event E (cont.) Notes:  Weights may be assigned in any fashion in Step 2, as long as both conditions are met.  Usually we choose weights that make sense in reality.  A probability model is a sample space S together with probabilities for each element of S.  If each element of sample space S has the same probability, the model is fair.

17 Example 3: Some Probability Models 3(a)  Experiment: Select a card from a deck of 52 cards.  Sample Space: S = {A , A, A , A , 2 , 2, 2 , 2  …, K , K, K , K  }  p(A  ) = p(A ) = … = p(K  ) = p(K  ) = 1/52  For the event “select a card with a diamond”,  E = {A , 2 , …, K  } and  p(E) = p(A  ) + p(2  ) + … + p(K  ) = 13/52 = 1/4.

18 Example 3: Some Probability Models (cont.) 3(b)  Experiment: Poll a group of voters on their choice in an election with three candidates, A, B, and C.  Sample Space: S = { A, B, C}  p(A) = 0.42; p(B) = 0.15; p(C) =  For the event “a voter chooses B or C”,  E = {B,C} and  p(E) = p(B) + p(C) = = 0.58.

19 Example 3: Some Probability Models (cont.) 3(c)  Experiment: Flip a coin, observe the up face.  Sample Space: S = {H, T}  p(H) = 1/2; p(T) = 1/2  For the event “the up face is Tail”,  E = {T} and  p(E) = 1/2.

20 Example 3: Some Probability Models (cont.) 3(d)  Experiment: Roll two six-sided dice, observe up faces.  Sample Space: S = {(1,1), (1,2), (1,3), (1,4), (1,5), (1,6), …, (6,1), (6,2), (6,3), (6,4), (6,5), (6,6)}  p((i,j)) = 1/36 for each i = 1,2, …, 6; j = 1, 2, …, 6.  For the event “roll a pair”,  E = {(1,1}, (2,2), (3,3), (4,4), (5,5), (6,6)}, so  p(E) = 1/36 + 1/36 + …+1/36 = 6/36 = 1/6.

21 Example 3: Some Probability Models (cont.) 3(e)  Experiment: Roll two six-sided dice, add the up faces.  Sample Space: S = {different possible sums} = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}  Using the probability model for example 3 (d), we find  p(2) = 1/36; p(3) = 2/36; p(4) = 3/36; p(5) = 4/36; p(6) = 5/36; p(7) = 6/36; p(8) = 5/36; p(9) = 4/36; p(10) = 3/36; p(11) = 2/36; p(12) = 1/36.  For the event “roll an odd sum”,  E = {3, 5, 7, 9, 11} and  p(E) = p(3) + p(5) + p(7) + p(9) + p(11)  = 2/36 + 4/36 + 6/36 + 4/36 + 2/36 = 18/36 = 1/2.

22 Remark on Fair Probability Models Examples 3(a), 3(c), and 3(d) are fair probability models. Notice that in each case, p(E) = (# elements in E)/(# elements in S). This is true in general for fair probability models! Notice that this property fails for examples 3(b) and 3(e). For example, in 3(e), # elements E = 5 and # elements in S = 11, but p(E) = 1/2.

23 Back to the Friedman Test! Now we are ready to look at the Friedman Test! The key to the Friedman Test is the Index of Coincidence.  The Index of Coincidence (IC) is the probability of two letters randomly selected from a text being equal.

24 Index of Coincidence The IC can be used to determine if a cipher is monoalphabetic or polyalphabetic. Given a piece of text, consider the experiment: “draw a pair of letters from the text letters at random”.  Sample Space:  S = {different possible pairs of letters that could be drawn from text letters} = {(a,a), (a,b), …, (z,y), (z,z)}.  Let event E be “draw a matching pair of letters”.  Thus, E = {(a,a), (b,b), …, (z,z)}.

25 Index of Coincidence (cont.) To compute p(E), we need to find the probability of each outcome in E. To do this, let  N = # letters in text  N 1 = # a’s in text  N 2 = # b’s in text ……  N 26 = # z’s in text Using FPC and the fact that any pair of letters has the same chance of being drawn, we find:

26 Index of Coincidence (cont.)

27 Index of Coincidence (cont.)

28 Index of Coincidence (cont.)

29 Index of Coincidence (cont.)

30 Index of Coincidence (cont.)

31 Index of Coincidence (cont.)

32 Index of Coincidence (cont.)

33 Index of Coincidence (cont.) Since p(E) = IC, it follows that for a piece of text,

34 Index of Coincidence (cont.) Since p(E) = IC, it follows that for a piece of text,

35 Index of Coincidence (cont.) Since p(E) = IC, it follows that for a piece of text, where N 1 = # a’s in text, N 2 = # b’s in text, …, N 26 = # z’s in text.

36 Index of Coincidence (cont.) Note that for a text with a large number of letters, N ≈ N-1 and N 1 ≈ N 1 -1, …, N 26 ≈ N Therefore, for large amounts of text, we can use this approximation to the IC:

37 Index of Coincidence (cont.) Note that for a text with a large number of letters, N ≈ N-1 and N 1 ≈ N 1 -1, …, N 26 ≈ N Therefore, for large amounts of text, we can use this approximation to the IC:

38 Index of Coincidence (cont.) Note that for a text with a large number of letters, N ≈ N-1 and N 1 ≈ N 1 -1, …, N 26 ≈ N Therefore, for large amounts of text, we can use this approximation to the IC: Thus, IC ≈ sum of squares of relative frequencies of the letters a, b, …, z!

39 Example 4: Find IC of Each! (a) English Language:  Using the relative frequency table for the English language (see handout or The Code Book—p. 19),  IC ≈ (0.082) 2 + (0.015) 2 + (0.028) 2 + … + (0.001) 2 = (b) A language in which each of 26 letters have the same relative frequency:  IC ≈ (1/26) 2 + (1/26) 2 + … + (1/26) 2 = 1/26 = (c) Any monoalphabetic cipher (in English):  The frequency distribution of the letters is the same as that of the English language, with the letters relabeled.  Therefore IC ≈

40 Final Remarks on the Friedman Test Example 4 suggests that if a polyalphabetic cipher is used, one will find an IC that is closer to 0.038, the case in which all 26 letters of the alphabet occur with the same frequency! Using the IC on a piece of ciphertext to guess the type of cipher is the Friedman Test. Another version of this test is used to find Vigenère cipher keyword lengths-see HW 2!