Unit 2.1
Unit 2.1
S.Y. SECTION A, B, C
ADVANCED CRYPTOGRAPHY
UNIT 2
Because learning changes everything.®
Unit No 2
Cryptographic Mathematics
© McGraw Hill LLC. All rights reserved. No reproduction or distribution without the prior written consent of McGraw Hill LLC.
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 LLC 3
Chapter Summary
Divisibility and Modular Arithmetic.
Integer Representations and Algorithms.
Primes and Greatest Common Divisors.
Solving Congruences.
Applications of Congruences.
Cryptography.
Division.
Division Algorithm.
Modular Arithmetic.
Integer Representations.
• Base b Expansions.
• Binary Expansions.
• Octal Expansions.
• Hexadecimal Expansions.
Base Conversion Algorithm.
Algorithms for Integer Operations.
q := q div b
k := k + 1
return
q represents the quotient obtained by successive divisions by b, starting with
q = n.
The digits in the base b expansion are the remainders of the division given by
q mod b.
The algorithm terminates when q = 0 is reached.
© McGraw Hill LLC 27
Base Conversion 2
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
c := d
return
The number of additions of bits used by the algorithm to add two n-bit
integers is O(n).
© McGraw Hill LLC 31
Binary Multiplication of Integers
Algorithm for computing the product of two n bit integers.
procedure multiply(a, b: positive integers)
{the binary expansions of a and b are
, respectively}
for j := 0 to n − 1
= a shifted j places
p := 0
for j := 0 to n − 1
p := p +
return p {p is the value of ab}
The number of additions of bits used by the algorithm to multiply two
n-bit integers is
© McGraw Hill LLC 32
Binary Modular Exponentiation
In cryptography, it is important to be able to find mod m
efficiently, where b, n, and m are large integers.
Use the binary expansion of n, n = (ak-1, , a1,ao)2 , to
compute
Note that:
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.
Access the text alternative for slide images.
This formula is valid since the integer on the right (of the equals sign)
divides both a and b. No larger integer can divide both a and b.
Example:
Finding the gcd of two positive integers using their prime factorizations
is not efficient because there is no efficient algorithm for finding the
prime factorization of a positive integer.
© McGraw Hill LLC 49
Least Common Multiple
Definition: The least common multiple of the positive integers a and b is
the smallest positive integer that is divisible by both a and b. It is
denoted by lcm(a,b).
The least common multiple can also be computed from the prime
factorizations.
• Divide 287 by 91
• Divide 91 by 14
• Divide 14 by 7
Stopping condition
Linear Congruences.
The Chinese Remainder Theorem.
Computer Arithmetic with Large Integers (not
currently included in slides, see text).
Fermat’s Little Theorem.
Pseudorandom.
Primitive Roots and Discrete Logarithms.
(optional) Carmichael
(1879-1967)
There are composite integers n that pass all tests with bases
b such that gcd(b,n) = 1.
Definition: A composite integer n that satisfies the congruence ≡ 1 (mod n)
for all positive integers b with gcd(b,n) = 1 is called a Carmichael number.
Example: The integer 561 is a Carmichael number. To see this:
• 561 is composite, since 561 =
• If gcd(b, 561) = 1, then gcd(b, 3) = 1, then gcd(b, 11) = gcd(b, 17) =1.
• Using Fermat’s Little Theorem:
• Then
• It follows (see Exercise 29) that ≡ 1 (mod 561) for all positive integers b with
gcd(b,561) = 1. Hence, 561 is a Carmichael number.
Even though there are infinitely many Carmichael numbers, there are other tests
(described in the exercises) that form the basis for efficient probabilistic
primality testing. (see Chapter 7)
© McGraw Hill LLC 75
Primitive Roots
Definition: A primitive root modulo a prime p is an integer r in
such that every nonzero element of is a power of r.
Example: Since every element of is a power of 2, 2 is a
primitive root of 11.
Powers of 2 modulo 11:
Hashing Functions.
Pseudorandom Numbers.
Check Digits.
Solution: Compute the terms of the sequence by successively using the congruence
a. Suppose that the first 11 digits of the UPC are 79357343104. What is the check digit?
b. Is 041331021641 a valid UPC?
Solution:
a.
b.
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)
© McGraw Hill LLC 84
Section Summary 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 , 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
by f(p) in the set
• 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.”
© McGraw Hill LLC 86
Caesar Cipher 2
To recover the original message, use (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
(p) = (p−k) mod 26
The integer k is called a key.
© McGraw Hill LLC 87
Shift Cipher 1
11 4 22 11 24 15 11 20 9 1 15 25 7 13 24 11 7 0 0 11 7 9 14
11 24.
A public key cryptosystem, now known as the RSA system was introduced in
1976 by three researchers at MIT.
It is now known that the method was discovered earlier by Clifford Cocks,
working secretly for the UK government.
With the decryption key d, we can decrypt each block with the computation
(see text for full derivation)
RSA works as a public key system since the only known method of finding d is based on
a factorization of n into primes. There is currently no known feasible method for
factoring large numbers into primes.
Example: The message 0981 0461 is received. What is the decrypted message if it was
encrypted using the RSA cipher from the previous example.
Solution: The message was encrypted with n = and exponent 13. An inverse of
= 2436 (exercise 2 in Section 4.4) is d = 937.
• To decrypt a block C, M =
To find the secret information from the public information would require the adversary
to find respectively. This is an instance of the
discrete logarithm problem, considered to be computationally infeasible when p and a
are sufficiently large.
© McGraw Hill LLC 100
Cryptographic Protocols: Digital
Signatures 1
Example: Suppose Alice’s RSA cryptosystem is the same as in the earlier example with
key(2537,13), 2537 = 43 59, p = 43 and q = 59 are primes and