3746 Number
3746 Number
3746 Number
Cryptography
Primes and Related Congruence
Equations
Objectives
❏ To introduce prime numbers and their applications
in cryptography.
❏ ❏ To discuss factorization algorithms and their
applications in cryptography.
❏ To describe the Chinese remainder theorem and its
application.
❏ To introduce quadratic congruence.
❏ To introduce modular exponentiation and
logarithm.
9.2
Topics discussed in this section:
Definition
Cardinality of Primes
Checking for Primeness
Euler’s Phi-Function
Fermat’s Little Theorem
Euler’s Theorem
Generating Primes
9.3
Three groups of positive integers
Note
A prime is divisible only by itself and 1.
9.4
Example
What is the smallest prime?
Solution
The smallest prime is 2, which is divisible by 2 (itself) and 1.
Example
List the primes smaller than 10.
Solution
There are four primes less than 10: 2, 3, 5, and 7. It is interesting
to note that the percentage of primes in the range 1 to 10 is 40%.
The percentage decreases as the range increases.
9.5
Infinite Number of Primes
Note
There is an infinite number of primes.
Number of Primes
9.6
Example
As a trivial example, assume that the only primes are in the set
{2, 3, 5, 7, 11, 13, 17}. Here P = 510510 and P + 1 = 510511.
However, 510511 = 19 × 97 × 277; none of these primes were in the
original list. Therefore, there are three primes greater than 17.
Example
Solution
The approximation gives the range 72,383 to 78,543. The actual
number of primes is 78,498.
9.7
Given a number n, how can we determine if n is a prime?
The answer is that we need to see if the number is
divisible by all primes less than
9.8
9.9
Example
Is 97 a prime?
Solution
The floor of 97 = 9. The primes less than 9 are 2, 3, 5, and 7. We
need to see if 97 is divisible by any of these numbers. It is not, so
97 is a prime.
Example
Is 301 a prime?
Solution
The floor of 301 = 17. We need to check 2, 3, 5, 7, 11, 13, and 17.
The numbers 2, 3, and 5 do not divide 301, but 7 does. Therefore
301 is not a prime.
9.10
Euler’s Phi-Function
9.11
We can combine the above four rules to find the value of
f(n). For example, if n can be factored as
n = p1e × p2e × … × pke
1 2 k
Note
The difficulty of finding f(n) depends on the
difficulty of finding the factorization of n.
9.12
Example
What is the value of f(13)?
Solution
Because 13 is a prime, f(13) = (13 −1) = 12.
Example
What is the value of f(10)?
Solution
We can use the third rule: f(10) = f(2) × f(5) = 1 × 4 = 4, because 2
and 5 are primes.
9.13
Example
What is the value of f(240)?
Solution
We can write 240 = 24 × 31 × 51. Then
Example
Can we say that f(49) = f(7) × f(7) = 6 × 6 = 36?
Solution
No. The third rule applies when m and n are relatively prime.
Here 49 = 72. We need to use the fourth rule: f(49) = 72 − 71 = 42.
9.14
Example 9.11
What is the number of elements in Z14*?
Solution
The answer is f(14) = f(7) × f(2) = 6 × 1 = 6. The members are 1,
3, 5, 9, 11, and 13.
Note
Interesting point: If n > 2, the value of f(n) is even.
9.15
Fermat’s Little Theorem
First Version
ap − 1 ≡ 1 mod p
Second Version
ap ≡ a mod p
9.16
Example
Find the result of 610 mod 11.
Solution
We have 610 mod 11 = 1. This is the first version of Fermat’s little
theorem where p = 11.
Example
Find the result of 312 mod 11.
Solution
Here the exponent (12) and the modulus (11) are not the same.
With substitution this can be solved using Fermat’s little theorem.
9.17
Multiplicative Inverses
9.18
Euler’s Theorem
First Version
af(n) ≡ 1 (mod n)
Second Version
a k × f(n) + 1 ≡ a (mod n)
Note
Example
Example
Find the result of 2062 mod 77.
Solution
If we let k = 1 on the second version, we have
2062 mod 77 = (20 mod 77) (20f(77) + 1 mod 77) mod 77
= (20)(20) mod 77 = 15.
9.20
Multiplicative Inverses
Euler’s theorem can be used to find multiplicative
inverses modulo a composite.
9.21
Example 9.17
The answers to multiplicative inverses modulo a composite can be
found without using the extended Euclidean algorithm if we know
the factorization of the composite:
9.22
9.24
9-4 CHINESE REMAINDER THEOREM
9.37
9-4 Continued
Example 9.35
The following is an example of a set of equations with different
moduli:
The solution to this set of equations is given in the next section; for
the moment, note that the answer to this set of equations is x = 23.
This value satisfies all equations: 23 ≡ 2 (mod 3), 23 ≡ 3 (mod 5),
and 23 ≡ 2 (mod 7).
9.38
9-4 Continued
9.39
9-4 Continued
Example 9.36
Solution
We follow the four steps.
1. M = 3 × 5 × 7 = 105
9.40
9-4 Continued
Example 9.37
Find an integer that has a remainder of 3 when divided by 7 and
13, but is divisible by 12.
Solution
This is a CRT problem. We can form three equations and solve
them to find the value of x.
9.53
9.6.1 Exponentiation
Fast Exponentiation
9.54
9.6.1 Continued
9.55
9.6.1 Continued
Example 9.45
Figure 9.7 shows the process for calculating y = ax using the
Algorithm 9.7 (for simplicity, the modulus is not shown). In this
case, x = 22 = (10110)2 in binary. The exponent has five bits.
9.56
9.6.1 Continued
9.57
9.6.2 Logarithm
9.58
9.6.2 Continued
Example 9.46
What is the order of group G = <Z21∗, ×>? |G| = f(21) = f(3) × f(7)
= 2 × 6 =12. There are 12 elements in this group: 1, 2, 4, 5, 8, 10,
11, 13, 16, 17, 19, and 20. All are relatively prime with 21.
9.60
9.6.2 Continued
Order of an Element
Example 9.47
Find the order of all elements in G = <Z10∗, ×>.
Solution
This group has only f(10) = 4 elements: 1, 3, 7, 9. We can find the
order of each element by trial and error.
Euler’s Theorem
Example 9.48
9.62
9.6.2 Continued
Example 9.49
Table 9.4 shows that there are no primitive roots in G = <Z8∗, ×>
because no element has the order equal to f(8) = 4. The order of
elements are all smaller than 4.
9.63
9.6.2 Continued
Example 9.50
Table 9.5 shows the result of ai ≡ x (mod 7) for the group
G = <Z7∗, ×>. In this group, f(7) = 6.
9.64
9.6.2 Continued
Note
The group G = <Zn*, ×> has primitive roots only if
n is 2, 4, pt, or 2pt.
Example 9.51
For which value of n, does the group G = <Zn∗, ×> have primitive
roots: 17, 20, 38, and 50?
Solution
a. G = <Z17∗, ×> has primitive roots, 17 is a prime.
b. G = <Z20∗, ×> has no primitive roots.
c. G = <Z38∗, ×> has primitive roots, 38 = 2 × 19 prime.
d. G = <Z50∗, ×> has primitive roots, 50 = 2 × 52 and 5 is a prime.
9.65
9.6.2 Continued
Note
If the group G = <Zn*, ×> has any primitive root,
the number of primitive roots is f(f(n)).
9.66
9.6.2 Continued
9.67
9.6.2 Continued
9.69
9.6.2 Continued
Example 9.53
Solution
We can easily use the tabulation of the discrete logarithm in
Table 9.6.
a. 4 ≡ 3x mod 7 → x = L34 mod 7 = 4 mod 7
b. 6 ≡ 5x mod 7 → x = L56 mod 7 = 3 mod 7
9.70
9.6.2 Continued
9.71