Chapter4 V02 Amal V02
Chapter4 V02 Amal V02
Cryptography
Chapter 4
© 2019 McGraw-Hill Education. All rights reserved. Authorized only for instructor use in the classroom. No reproduction or further distribution permitted without the prior written consent of McGraw-Hill Education.
Chapter Motivation
• Number theory is the part of mathematics devoted to the study
of the integers and their properties.
• Key ideas in number theory include divisibility and the primality
of integers.
• Representations of integers, including binary and hexadecimal
representations, are part of number theory.
• Number theory has long been studied because of the beauty of
its ideas, its accessibility, and its wealth of open questions.
• We’ll use many ideas developed in Chapter 1 about proof
methods and proof strategy in our exploration of number theory.
• Mathematicians have long considered number theory to be pure
mathematics, but it has important applications to computer
science and cryptography studied in Sections 4.5 and 4.6.
©McGraw-Hill Education
Chapter Motivation
• Number theory is the part of mathematics devoted to the study
of the integers and their properties.
• Key ideas in number theory include divisibility and the primality
of integers.
• Representations of integers, including binary and hexadecimal
representations, are part of number theory.
• Number theory has long been studied because of the beauty of
its ideas, its accessibility, and its wealth of open questions.
• We’ll use many ideas developed in Chapter 1 about proof
methods and proof strategy in our exploration of number theory.
• Mathematicians have long considered number theory to be pure
mathematics, but it has important applications to computer
science and cryptography studied in Sections 4.5 and 4.6.
© 2019 McGraw-Hill Education
Chapter Summary
• 4.1. Divisibility and Modular Arithmetic
• Integer Representations and Algorithms
• 4.3. Primes and Greatest Common Divisors
• 4.4. Solving Congruences
• 4.5. Applications of Congruences (self study)
• 4.6. Cryptography (Caesar cipher) -> Online
tutorial during the weekend
4.1.1 Division
4.1.2 Division Algorithm
4.1.3 Modular Arithmetic
Can you show how it follows easily from (ii) and (i) of Theorem 1?
© 2019 McGraw-Hill Education
Division Algorithm
When an integer is divided by a positive integer, there is a quotient and a
remainder. This is traditionally called the “Division Algorithm,” but is really a
theorem.
Division Algorithm: If a is an integer and d a positive integer, then there are
unique integers q and r, with 0 ≤ r < d, such that a = dq + r (proved in Section 5.2).
• d is called the divisor.
Definitions of Functions
• a is called the dividend.
div and mod
• q is called the quotient.
q = a div d
• r is called the remainder.
r = a mod d
Examples:
• What are the quotient and remainder when 101 is divided by 11?
• Solution: The quotient when 101 is divided by 11 is 9 = 101 div 11, and the
remainder is 2 = 101 mod 11.
• What are the quotient and remainder when −11 is divided by 3?
• Solution: The quotient when −11 is divided by 3 is −4 = −11 div 3, and the remainder
is 1 = −11 mod 3.
© 2019 McGraw-Hill Education
Congruence Relation
Definition: If a and b are integers and m is a positive integer, then a
is congruent to b modulo m if m divides a − b.
• The notation a ≡ b (mod m) says that a is congruent to b modulo m.
• We say that a ≡ b (mod m) is a congruence and that m is its modulus.
• Two integers are congruent mod m if and only if they have the same
remainder when divided by m.
• If a is not congruent to b modulo m, we write a ≢ b (mod m)
• a ∙m (b +m c) = (a ∙m b) +m (a ∙m c) and (a +m b) ∙m c = (a ∙m c) +m (b ∙m
c).
Hashing Functions
Pseudorandom Numbers
Check Digits
x0 = 3.
Solution: Compute the terms of the sequence by successively using the congruence
xn 1 (7 xn 4) mod 9, with x0 3.
x1 7 x0 4 mod 9 7 3 4 mod 9 25 mod 9 7,
x2 7 x1 4 mod 9 7 7 4 mod 9 53 mod 9 8,
x3 7 x2 4 mod 9 7 8 4 mod 9 60 mod 9 6,
x4 7 x3 4 mod 9 7 6 4 mod 9 46 mod 9 1,
x5 7 x4 4 mod 9 7 1 4 mod 9 11 mod 9 2,
x6 7 x5 4 mod 9 7 2 4 mod 9 18 mod 9 0,
x7 7 x6 4 mod 9 7 0 4 mod 9 4 mod 9 4,
x8 7 x7 4 mod 9 7 4 4 mod 9 32 mod 9 5,
The validity of an ISBN-10 number can be evaluated with the equivalent ix i 0 mod 11.
i 1
a. Suppose that the first 9 digits of the ISBN-10 are 007288008. What is the check digit?
b. Is 084930149X a valid ISBN10?
X is used
Solution:
for the
a. X10 ≡ 1∙0 + 2∙0 + 3∙7 + 4∙2 + 5∙8 + 6∙8 + 7∙ 0 + 8∙0 + 9∙8 (mod 11). digit 10.
X10 ≡ 0 + 0 + 21 + 8 + 40 + 48 + 0 + 0 + 72 (mod 11).
X10 ≡ 189 ≡ 2 (mod 11). Hence, X10 = 2.
b. 1∙0 + 2∙8 + 3∙4 + 4∙9 + 5∙3 + 6∙0 + 7∙ 1 + 8∙4 + 9∙9 + 10∙10 =
0 + 16 + 12 + 36 + 15 + 0 + 7 + 32 + 81 + 100 = 299 ≡ 2 ≢ 0 (mod 11)
Hence, 084930149X is not a valid ISBN-10.
A single error is an error in one digit of an identification number and a transposition error is the
accidental interchanging of two digits. Both of these kinds of errors can be detected by the check
digit for ISBN-10. (see text for more details)
© 2019 McGraw-Hill Education
Cryptography
Section 4.6
Classical Cryptography
Cryptosystems
Public Key Cryptography
RSA Cryptosystem
Cryptographic Protocols
Primitive Roots and Discrete Logarithms
Julius Caesar created secret messages by shifting each letter three letters forward in the
alphabet (sending the last three letters to the first three letters.) For example, the letter B
is replaced by E and the letter X is replaced by A. This process of making a message
secret is an example of encryption.
Here is how the encryption process works:
• Replace each letter by an integer from Z26, that is an integer from 0 to 25 representing one less
than its position in the alphabet.
• The encryption function is f(p) = (p + 3) mod 26. It replaces each integer p in the set {0,1,2,
…,25} by f(p) in the set {0,1,2,…,25} .
• Replace each integer p by the letter with the position p + 1 in the alphabet.
Example: Encrypt the message “MEET YOU IN THE PARK” using the Caesar cipher.
Solution: 12 4 4 19 24 14 20 8 13 19 7 4 15 0 17 10.
Now replace each of these numbers p by f(p) = (p + 3) mod 26.
15 7 7 22 1 17 23 11 16 22 10 7 18 3 20 13.
Translating the numbers back to letters produces the encrypted message
“PHHW BRX LQ WKH SDUN.”
© 2019 McGraw-Hill Education
Caesar Cipher 2
To recover the original message, use f−1(p) = (p−3) mod 26. So,
each letter in the coded message is shifted back three letters in
the alphabet, with the first three letters sent to the last three
letters. This process of recovering the original message from the
encrypted message is called decryption.
The Caesar cipher is one of a family of ciphers called shift
ciphers. Letters can be shifted by an integer k, with 3 being just
one possibility. The encryption function is
f(p) = (p + k) mod 26
and the decryption function is
f−1(p) = (p−k) mod 26
The integer k is called a key.
© 2019 McGraw-Hill Education
Shift Cipher 1
18 19 14 15 6 11 14 1 0 11 22 0 17 12
8 13 6.
Apply the shift f(p) = (p + 11) mod 26, yielding
3 4 25 0 17 22 25 12 11 22 7 11 2 23
19 24 17.
Translating the numbers back to letters produces the ciphertext