04 1 Number Theory
04 1 Number Theory
Cryptography
Chapter 4
With Question/Answer
Animations
Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution 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
of Theorem 1?
Can you show how it follows easily from from (ii) and (i)
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.
then there are unique integers q and r, with 0 ≤ r < d, such that a
Division Algorithm: If a is an integer and d a positive integer,
a ≢ b (mod m)
If a is not congruent to b modulo m, we write
Solution:
17 ≡ 5 (mod 6) because 6 divides 17 − 5 = 12.
24 ≢ 14 (mod 6) since 24 − 14 = 10 is not divisible by 6.
More on Congruences
Theorem 4: Let m be a positive integer. The
integers a and b are congruent modulo m if
and only if there is an integer k such that a =
b + km.
Proof:
If a ≡ b (mod m), then (by the definition of
congruence) m | a – b. Hence, there is an
integer k such that a – b = km and equivalently
a = b + km.
Conversely, if there is an integer k such that a
Zm .
Associativity: If a, b, and c belong to Zm , then
(a ∙m b) ∙m c = a ∙m (b ∙m c).
(a +m b) +m c = a +m (b +m c) and
a +m b = b +m a and a ∙m b = b ∙m
Commutativity: If a and b belong to Zm , then
→
continued
Arithmetic Modulo m
Additive inverses: If a≠ 0 belongs to Zm , then m− a is the
additive inverse of a modulo m and 0 is its own additive
a + (m− a ) = 0 and 0 + 0 = 0
inverse.
m 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).
quotient is 0.
remainder. The process terminates when the
continued →
Algorithm: Constructing Base b Expansions
1)
procedure base b expansion(n, b: positive integers with b >
k := 0
q := n
while (q ≠ 0)
ak := q mod b
k := k + 1
q := q div b
3 =8∙0+3
The remainders are the digits from right to
left yielding (30071)8.
Comparison of Hexadecimal, Octal, and
Binary Representations
Solution:
c := 0
respectively}
for j := 0 to n − 1
d := ⌊(aj + bj + c)/2⌋
sj := aj + bj + c − 2d
c := d
sn := c
return(s0,s1,…, sn){the binary expansion of the sum is (sn,sn-1,…,s0)2}
The number of additions of bits used by the algorithm to
add two n-bit integers is O(n).
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 (an-1,an-2,…,a0)2 and (bn-1,bn-2,…,b0)2, respectively}
for j := 0 to n − 1
if bj = 1 then cj = a shifted j places
else cj := 0
{co,c1,…, cn-1 are the partial products}
p := 0
for j := 0 to n − 1
p := p + cj
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
O(n2).
Binary Modular Exponentiation
In cryptography, it is important to be able to find bn 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 bn .
Note that:
x := 1
positive integers)
for i := 0 to k − 1
power := b mod m