ZCh2 Number Theory
ZCh2 Number Theory
Network Security
Seventh Edition, Global Edition
by William Stallings
Chapter 2
Introduction to Number Theory
• If a | b and b | a, then a = ±b
11/2/2023 8
Module #9 – Number Theory
Example
• What are the quotient and the remainder when −11
is divided by 3?
−11 = 3 × (−4) + 1
q = −4 , r = 1
− 11
q = −11 div 3 = = − 3.6 = −4
3
r = −11 − (−4) 3 = 1 = −11 mod 3
r = p mod n = p – (q × n)
r = -11 mod 3 = -11 – (-4×3)= -11 +12 = 1
11/2/2023 9
• One of the basic
Euclidean
techniques of number
theory
11/2/2023 12
GCD
• Because we require that the greatest common divisor be positive,
gcd(a,b) = gcd(a,- b) = gcd(- a, b) = gcd(- a,- b)
73 mod 23 = 4 mod 23
4 = 4
1. a b (mod n) if n | (a – b)
11 mod 8 = 3; 15 mod 8 = 7
[(11 mod 8) + (15 mod 8)] mod 8 = 10 mod 8 = 2
(11 + 15) mod 8 = 26 mod 8 = 2
[(11 mod 8) - (15 mod 8)] mod 8 = - 4 mod 8 = 4
(11 - 15) mod 8 = - 4 mod 8 = 4
[(11 mod 8) * (15 mod 8)] mod 8 = 21 mod 8 = 5
(11 * 15) mod 8 = 165 mod 8 = 5
© 2017 Pearson Education, Ltd., All rights reserved. (This table can be found on page 37 in the textbook)
Table 2.2(b)
Multiplication Modulo 8
© 2017 Pearson Education, Ltd., All rights reserved. (This table can be found on page 37 in the textbook)
Additive and Multiplicative Inverse Modulo 8
• The multiplicative inverse, or reciprocal of x is the integer y such that
(x * y ) mod 8 = 1 mod 8. Now, to find the multiplicative inverse of an
integer from the multiplication table, scan across the matrix in the row for
that integer to find the value 1; the integer at the top of that column is the
multiplicative inverse; thus, (3 * 3) mod 8 = 1.
• Note that not all integers mod 8 have a multiplicative inverse. No
multiplicative inverse for 2.
Additive
and
Multiplicative
Inverse
Modulo 8
© 2017 Pearson Education, Ltd., All rights reserved. (This table can be found on page 37 in the textbook)
Table 2.3
Properties of Modular Arithmetic for Integers in Zn
© 2017 Pearson Education, Ltd., All rights reserved. (This table can be found on page 44 in the textbook)
Prime Numbers
• Prime numbers only have divisors of 1 and itself
• They cannot be written as a product of other numbers
Prime Factorization
30 11/2/2023
Fermat's Theorem
• States the following:
• If p is prime and a is a positive integer not divisible
by p then
ap-1 1 (mod p)
e.g: Let p=3 and a=10 then 102 1 (mod3)
• An alternate form is:
• If p is prime and a is a positive integer then
ap a (mod p)
103 10 (mod 3)
• Table 2.6 lists the first 30 values of ø (n ). The value ø(1) is without
meaning but is defined to have the value 1.
• ø(13) = 12 → 1,2,3,4,5,6,7,8,9,10,11,12
© 2017 Pearson Education, Ltd., All rights reserved. (This table can be found on page 48 in the textbook)
Euler's Theorem
• States that for every a and n that are relatively
prime:
aø(n) 1 (mod n)
e.g a=7 and n=5 are relatively prime, so
7ø(5)=4 1 (mod 5) → 2401 1 (mod 5)
2401/5 = 480 and r=1
• An alternative form is:
aø(n)+1 a(mod n)
4. • for j = 0 to k – 1 do
6. • return (“composite") ;
© 2017 Pearson Education, Ltd., All rights reserved.
Deterministic Primality Algorithm
• Prior to 2002 there was no known method of
efficiently proving the primality of very large
numbers
• All of the algorithms in use produced a probabilistic
result
• In 2002 Agrawal, Kayal, and Saxena developed an
algorithm that efficiently determines whether a
given large number is prime
• Known as the AKS algorithm
• Does not appear to be as efficient as the
Miller-Rabin algorithm
© 2017 Pearson Education, Ltd., All rights reserved. (This table can be found on page 57 in the textbook)
Table 2.8
Tables of Discrete Logarithms, Modulo 19