Chapter4 - Cryptography
Chapter4 - Cryptography
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.
Division
Division Algorithm
Modular Arithmetic
• 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).
Integer Representations
• Base b Expansions
• Binary Expansions
• Octal Expansions
• Hexadecimal Expansions
Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F
Octal 0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17
Binary 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111
If an integer n is a
composite integer, then
it has a prime divisor
less than or equal to √n.
To see this, note that if
n = ab, then a ≤ √n or b
≤√n.
Trial division, a very
inefficient method of
determining if a number
n is prime, is to try
every integer i ≤√n and
see if n is divisible by i.
© 2019 McGraw-Hill Education
Distribution of Primes
Mathematicians have been interested in the distribution
of prime numbers among the positive integers. In the
nineteenth century, the prime number theorem was
proved which gives an asymptotic estimate for the
number of primes not exceeding x.
Prime Number Theorem: The ratio of the number of
primes not exceeding x and x/ln x approaches 1 as x
grows without bound. (ln x is the natural logarithm of x)
• The theorem tells us that the number of primes not exceeding
x, can be approximated by x/ln x.
• The odds that a randomly selected positive integer less than n
is prime are approximately (n/ln n)/n = 1/ln n.
© 2019 McGraw-Hill Education
Greatest Common Divisor 1
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
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 + 3 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.”
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
“DEZA RWZMLW HLCXTYR.”
© 2019 McGraw-Hill Education
Shift Cipher 2