codes and cryptography - school of mathematics and - mathsface

49
Codes and Cryptography School of Mathematics and Statistics, UWA John Bamberg and Adrian Dudek

Upload: others

Post on 09-Feb-2022

1 views

Category:

Documents


0 download

TRANSCRIPT

Codes and CryptographySchool of Mathematics and Statistics, UWA

John Bamberg and Adrian Dudek

Introduction

Every development in modern technology relies on a new way of storing,exchanging and presenting information.

• Television• The Internet• Mobile Phones

Of course, we live in a time whereall three of these appear in a singledevice!

Reliable Information

When you send an SMS to somebody ...

... your message gets turned into a string of 0’s and 1’s before it gets sentout. This string hits their phone and gets translated back to English.

“lol”⇒ “011011000110111101101100”⇒ “lol”

Our encoded message might get muddled. If the 0 on the end getschanged changed to a 1 it could be disastrous!

“lol”⇒ERROR “011011000110111101101101”⇒ “lom”

It is important that we develop error-detecting and error-correcting codes!

Detecting errors in messagesBar codes, ISBN numbers and Credit cards

• What happens when you are buying apple juice in the supermarket,but there is a mistake on the bar code?

• Thanks to mathematics, supermarket bar codes are a reliable andsafe way to label supermarket items.

Checking for an error in the code

• There are 13 numbers, the last is the check digit.• Add up the numbers in the odd places (1st, 3rd, 5th, 7th, 9th, 11th)

and multiply by 3.• Add up the numbers in the even places (2nd, 4th, 6th, 8th, 10th,

12th) and add it to the previous number.• Take the last digit.• If the last digit in the barcode is not this number, then the bar code is

not valid.

Which of the following bar codes is valid?

1. 9300657111663

←− Heinz tomato sauce

2. 9310577280276

←− not valid

3. 9300605003811

←− Milo

Which of the following bar codes is valid?

1. 9300657111663←− Heinz tomato sauce

2. 9310577280276

←− not valid

3. 9300605003811

←− Milo

Which of the following bar codes is valid?

1. 9300657111663←− Heinz tomato sauce

2. 9310577280276←− not valid

3. 9300605003811

←− Milo

Which of the following bar codes is valid?

1. 9300657111663←− Heinz tomato sauce

2. 9310577280276←− not valid

3. 9300605003811←− Milo

Clock arithmetic

• What day of the week is it on the 1st of July?• If a clock has 13 numbers, then what time is it 6 hours later than

10am?

Addition modulo mWe write

a ⊕m b

for the remainder of a + b after we have divided out m.

Example:• 10 ⊕13 6 = 3• 5 ⊕3 11 = 1

Calculate the following:

(a) 3 ⊕5 4

(b) −4 ⊕3 10

ISBN numbers

ISBN number

• Consists of nine numbers from {0, 1, 2, 3, 4, 5, 6, 7, 8, 9,X}, pluscheck digit.

• We think of X as representing the number 10, just like in Romannumerals.

• To check that an ISBN number is valid, we do

x1 ⊕11 2x2 ⊕11 3x3 ⊕11 · · · ⊕11 10x10 = 0

Show that the following ISBN number is valid:

0-385-49532-3

←−“The Code Book” by Simon Singh”

ISBN numbers

ISBN number

• Consists of nine numbers from {0, 1, 2, 3, 4, 5, 6, 7, 8, 9,X}, pluscheck digit.

• We think of X as representing the number 10, just like in Romannumerals.

• To check that an ISBN number is valid, we do

x1 ⊕11 2x2 ⊕11 3x3 ⊕11 · · · ⊕11 10x10 = 0

Show that the following ISBN number is valid:

0-385-49532-3←−“The Code Book” by Simon Singh”

Credit cards

Visa cards and Mastercard cards

• Have sixteen numbers.• To check that it is a valid number we do the following:

• Starting from the first number and moving right, double the value ofevery second digit.

• If the number has two digits, replace it with its sum (e.g., 13→ 4).• Sum these new digits and add them with the digits in the even places.• If the total is a multiple of 10 then the number is valid.

Is the following Visa card number valid?

4408-0412-3456-7890.

←− not valid

Credit cards

Visa cards and Mastercard cards

• Have sixteen numbers.• To check that it is a valid number we do the following:

• Starting from the first number and moving right, double the value ofevery second digit.

• If the number has two digits, replace it with its sum (e.g., 13→ 4).• Sum these new digits and add them with the digits in the even places.• If the total is a multiple of 10 then the number is valid.

Is the following Visa card number valid?

4408-0412-3456-7890.←− not valid

Cheney’s card trick

• There will now be an amazing magic trick• This works just like an error-correcting code

Cheney’s card trick

How it works

• J = 11, Q = 12, K = 13

• From five cards, at least two have the same suit.• Choose hidden card so that you can “⊕136” to get the number:

Jr and 3r −→ hide 3r, since 11 ⊕13 5 = 3

• First card indicates the suit and the number to “add” to.• Then need to “encode” a number from 1, 2, 3, 4, 5, 6.

Cheney’s card trick

How it works

• J = 11, Q = 12, K = 13• From five cards, at least two have the same suit.

• Choose hidden card so that you can “⊕136” to get the number:

Jr and 3r −→ hide 3r, since 11 ⊕13 5 = 3

• First card indicates the suit and the number to “add” to.• Then need to “encode” a number from 1, 2, 3, 4, 5, 6.

Cheney’s card trick

How it works

• J = 11, Q = 12, K = 13• From five cards, at least two have the same suit.• Choose hidden card so that you can “⊕136” to get the number:

Jr and 3r −→ hide 3r, since 11 ⊕13 5 = 3

• First card indicates the suit and the number to “add” to.• Then need to “encode” a number from 1, 2, 3, 4, 5, 6.

Cheney’s card trick

How it works

• J = 11, Q = 12, K = 13• From five cards, at least two have the same suit.• Choose hidden card so that you can “⊕136” to get the number:

Jr and 3r −→ hide 3r, since 11 ⊕13 5 = 3

• First card indicates the suit and the number to “add” to.

• Then need to “encode” a number from 1, 2, 3, 4, 5, 6.

Cheney’s card trick

How it works

• J = 11, Q = 12, K = 13• From five cards, at least two have the same suit.• Choose hidden card so that you can “⊕136” to get the number:

Jr and 3r −→ hide 3r, since 11 ⊕13 5 = 3

• First card indicates the suit and the number to “add” to.• Then need to “encode” a number from 1, 2, 3, 4, 5, 6.

Cheney’s card trick

How it works

• The three cards can be ordered Small, Medium, Large

• Second card:S {1, 2}M {3, 4}L {5, 6}

• Third and fourth pick out “little” or “big” from the two cards.

Cheney’s card trick

How it works

• The three cards can be ordered Small, Medium, Large• Second card:

S {1, 2}M {3, 4}L {5, 6}

• Third and fourth pick out “little” or “big” from the two cards.

Cheney’s card trick

How it works

• The three cards can be ordered Small, Medium, Large• Second card:

S {1, 2}M {3, 4}L {5, 6}

• Third and fourth pick out “little” or “big” from the two cards.

Where are error-correcting codes used?

• Compact Discs (CDs)• DVDs• Bank cards• ISBN numbers on books• Mobile phones• iPods• Pictures sent from satellites• Modems, fax machines• Communication over a network

Lying once

Get yourselves into groups of two.

You will be versing each other in a game of secret keeping and lies!

The Game

The game is played as follows:

1. One of you is the secret keeper , the other is the detective.

2. The secret is a number from 0 to 15.

3. The detective may ask 7 questions with Yes/No answer

4. The secret keeper is allowed to lie at most once.5. After the 7 questions, the detective makes the guess.

• Correct: 1 point• Incorrect: -2 points• No guess: 0 points

6. Three turns at detective work each!

Go for it!

The Game

The game is played as follows:

1. One of you is the secret keeper , the other is the detective.

2. The secret is a number from 0 to 15.

3. The detective may ask 7 questions with Yes/No answer

4. The secret keeper is allowed to lie at most once.5. After the 7 questions, the detective makes the guess.

• Correct: 1 point• Incorrect: -2 points• No guess: 0 points

6. Three turns at detective work each!

Go for it!

The Game

The game is played as follows:

1. One of you is the secret keeper , the other is the detective.

2. The secret is a number from 0 to 15.

3. The detective may ask 7 questions with Yes/No answer

4. The secret keeper is allowed to lie at most once.5. After the 7 questions, the detective makes the guess.

• Correct: 1 point• Incorrect: -2 points• No guess: 0 points

6. Three turns at detective work each!

Go for it!

The Game

The game is played as follows:

1. One of you is the secret keeper , the other is the detective.

2. The secret is a number from 0 to 15.

3. The detective may ask 7 questions with Yes/No answer

4. The secret keeper is allowed to lie at most once.

5. After the 7 questions, the detective makes the guess.• Correct: 1 point• Incorrect: -2 points• No guess: 0 points

6. Three turns at detective work each!

Go for it!

The Game

The game is played as follows:

1. One of you is the secret keeper , the other is the detective.

2. The secret is a number from 0 to 15.

3. The detective may ask 7 questions with Yes/No answer

4. The secret keeper is allowed to lie at most once.5. After the 7 questions, the detective makes the guess.

• Correct: 1 point• Incorrect: -2 points• No guess: 0 points

6. Three turns at detective work each!

Go for it!

The Game

The game is played as follows:

1. One of you is the secret keeper , the other is the detective.

2. The secret is a number from 0 to 15.

3. The detective may ask 7 questions with Yes/No answer

4. The secret keeper is allowed to lie at most once.5. After the 7 questions, the detective makes the guess.

• Correct: 1 point• Incorrect: -2 points• No guess: 0 points

6. Three turns at detective work each!

Go for it!

The Game

The game is played as follows:

1. One of you is the secret keeper , the other is the detective.

2. The secret is a number from 0 to 15.

3. The detective may ask 7 questions with Yes/No answer

4. The secret keeper is allowed to lie at most once.5. After the 7 questions, the detective makes the guess.

• Correct: 1 point• Incorrect: -2 points• No guess: 0 points

6. Three turns at detective work each!

Go for it!

A Bad Way to Play

1. Is your secret number equal to 0? No

2. Is your secret number equal to 1? No

3. Is your secret number equal to 2? No

4. Is your secret number equal to 3? No

5. Is your secret number equal to 4? No

6. Is your secret number equal to 5? No

7. Is your secret number equal to 6? No

Good Questions

For those who won the game, what questions did you ask?

• Is your number prime?• Is your number even?• Is your number between 0 and 7?• Should we ever ask the same question twice? Or thrice?

Good Questions

For those who won the game, what questions did you ask?

• Is your number prime?

• Is your number even?• Is your number between 0 and 7?• Should we ever ask the same question twice? Or thrice?

Good Questions

For those who won the game, what questions did you ask?

• Is your number prime?• Is your number even?

• Is your number between 0 and 7?• Should we ever ask the same question twice? Or thrice?

Good Questions

For those who won the game, what questions did you ask?

• Is your number prime?• Is your number even?• Is your number between 0 and 7?

• Should we ever ask the same question twice? Or thrice?

Good Questions

For those who won the game, what questions did you ask?

• Is your number prime?• Is your number even?• Is your number between 0 and 7?• Should we ever ask the same question twice? Or thrice?

A Strategy Against those Quick to Lie

1. Is your number even? NO

If you think they have lied here, then you can beat them!

2. Is your number even? YES

Ok, so they did lie! Ask one more time to be sure if their first orsecond answer was the lie.

3. Is your number even? YES

Can we get their number now?

Detectives

Mathematicians make the best detectives,

• and we will prove this to you now!

• Ok, so it’s not the mathematicians which are good detectives, it’s theerror-correcting codes they create!

Detectives

Mathematicians make the best detectives,

• and we will prove this to you now!• Ok, so it’s not the mathematicians which are good detectives, it’s the

error-correcting codes they create!

The Hamming Code

• Richard Hamming (1915 – 1998)

• Hamming discovered his codes in 1950 (Bell Labs).• The Hamming code can detect up to two errors• The Hamming code can correct single errors• Widely used for computer memory (RAM)• The Hamming codes are perfect codes, every lie is

nearby the truth!

The Hamming Code

• Richard Hamming (1915 – 1998)• Hamming discovered his codes in 1950 (Bell Labs).

• The Hamming code can detect up to two errors• The Hamming code can correct single errors• Widely used for computer memory (RAM)• The Hamming codes are perfect codes, every lie is

nearby the truth!

The Hamming Code

• Richard Hamming (1915 – 1998)• Hamming discovered his codes in 1950 (Bell Labs).• The Hamming code can detect up to two errors

• The Hamming code can correct single errors• Widely used for computer memory (RAM)• The Hamming codes are perfect codes, every lie is

nearby the truth!

The Hamming Code

• Richard Hamming (1915 – 1998)• Hamming discovered his codes in 1950 (Bell Labs).• The Hamming code can detect up to two errors• The Hamming code can correct single errors

• Widely used for computer memory (RAM)• The Hamming codes are perfect codes, every lie is

nearby the truth!

The Hamming Code

• Richard Hamming (1915 – 1998)• Hamming discovered his codes in 1950 (Bell Labs).• The Hamming code can detect up to two errors• The Hamming code can correct single errors• Widely used for computer memory (RAM)

• The Hamming codes are perfect codes, every lie isnearby the truth!

The Hamming Code

• Richard Hamming (1915 – 1998)• Hamming discovered his codes in 1950 (Bell Labs).• The Hamming code can detect up to two errors• The Hamming code can correct single errors• Widely used for computer memory (RAM)• The Hamming codes are perfect codes, every lie is

nearby the truth!

0 1 2 3

4 5 6 7

8 9 10 11

12 13 14 15