25
Section 4.3: Fermat’s Little Theorem Practice HW (not to hand in) From Barr Text p. 284 # 1, 2

Section 4.3: Fermat’s Little Theorem

Embed Size (px)

DESCRIPTION

Section 4.3: Fermat’s Little Theorem. Practice HW (not to hand in) From Barr Text p. 284 # 1, 2. - PowerPoint PPT Presentation

Citation preview

Page 1: Section 4.3: Fermat’s Little Theorem

Section 4.3: Fermat’s Little Theorem

Practice HW (not to hand in)

From Barr Text

p. 284 # 1, 2

Page 2: Section 4.3: Fermat’s Little Theorem

• As we will see later, the RSA Cryptosystem will require exponentiation to encrypt and decrypt messages. In this section, we review the basics of exponentiation and demonstrate an efficient method for doing exponentiation in modular arithmetic.

Page 3: Section 4.3: Fermat’s Little Theorem

Exponential Notation

• Recall that exponential notation represents an expression of the form

,

where a represents the base of the expression and k represents the exponent. If the exponent k is a positive integer, then

ka

k times multiplied a

k aaaaa

Page 4: Section 4.3: Fermat’s Little Theorem

Example 1: Compute and .

Solution:

52 37

Page 5: Section 4.3: Fermat’s Little Theorem

In this section, we want to consider the problem

of computing

The next example illustrates a basic computation

with his quantity.

mak MOD

Page 6: Section 4.3: Fermat’s Little Theorem

Example 2: Compute .

Solution:

25 MOD 25

Page 7: Section 4.3: Fermat’s Little Theorem

The last example illustrates that it is easy to do

modular exponentiation when the exponent k is

small. However, if the exponent becomes larger,

this presents more of a challenge. If we are asked

to compute , for example, we should

note that , which due to size

causes errors in computations due to computer

round off. Our goal next is to present a method

that overcomes this problem.

41 MOD 785

7185 1081.67

Page 8: Section 4.3: Fermat’s Little Theorem

• Note: All laws of exponents in the real number system carry over to MOD arithmetic, except for division.

Page 9: Section 4.3: Fermat’s Little Theorem

Laws of Exponents

Real Number System Modular Number System

10 a 1 MOD 0 ma

lklk aaa mamaa lklk MOD MOD

kllk aa )( mama kllk MOD MOD )(

11 aa

1),gcd( if exists MOD 1 mama

lkl

k

aa

a 1),gcd( if exists MOD )( 1 mamaa lk

Page 10: Section 4.3: Fermat’s Little Theorem

Method of Successive Squaring for

• Idea is to break the exponent k into a sum of powers of 2 (starting with ) and break

in terms of exponential terms as these powers of 2, computing the powers of 2 by “successively squaring” the previous term.

mak MOD

02 ka

Page 11: Section 4.3: Fermat’s Little Theorem

Example 3: Compute

Solution:

23MOD 1311

Page 12: Section 4.3: Fermat’s Little Theorem
Page 13: Section 4.3: Fermat’s Little Theorem
Page 14: Section 4.3: Fermat’s Little Theorem

Example 4: Compute

Solution: We first note that the exponent k = 85.

We first determine the powers of 2 that are less

than this exponent. Starting with, we see that

, , , , , ,

We can stop at since

41MOD 785

120 221 422 823 1624 3225 6426

6426 .8512827

Page 15: Section 4.3: Fermat’s Little Theorem

We now decompose the exponent k into powers

of 2.

We next write

We next compute the needed powers of 7

needed with respect to the modulus 41. The

ones that we will need are indicated by . Note

that arrows are used to indicate the substitutions

from the previous step.

64164114166451664216485

41MOD )7777(41MOD 741MOD 7 64164164164185

Page 16: Section 4.3: Fermat’s Little Theorem

741MOD71

841MOD4941MOD72

2341MOD6441MOD)8(41MOD)7(41MOD7 2224

3741MOD52941MOD)23(41MOD)7(41MOD7 2248

1641MOD136941MOD)37(41MOD)7(41MOD7 22816

1041MOD25641MOD)16(41MOD)7(41MOD7 221632

1841MOD10041MOD)10(41MOD)7(41MOD7 223264

Page 17: Section 4.3: Fermat’s Little Theorem

Hence,

3841MOD7Hence,38

41MOD38

141MOD288and3841MOD161Note41MOD)138(

2881816and161237thatNote41MOD)288161(

aboves'fromngSubstituti41MOD)1816237(

41MOD)7777(

41MOD7417

85

641641

64164185

MOD

Page 18: Section 4.3: Fermat’s Little Theorem

Note

• In Example 4, to compute by ordinary exponentiation, 84 multiplications are required. Using successive squares requires only 9 multiplications.

41 MOD 785

Page 19: Section 4.3: Fermat’s Little Theorem

Fermat’s Little Theorem

Fermat’s Little Theorem in special cases can be

used to simplify the process of modular

exponentiation. We state it now.

Fermat’s Little Theorem: Let p be a prime

number, a an integer where . Then

1. If , then .

2. .

pa 11),gcd( pa 1 MOD 1 pa p

apa p MOD

Page 20: Section 4.3: Fermat’s Little Theorem

Example 5: Use Fermat’s Little Theorem to

calculate the remainder when x is divided by the

given divisor m, that is, calculate x MOD m.

a. , m = 31.

Solution:

3021x

Page 21: Section 4.3: Fermat’s Little Theorem

b. , m = 941.

Solution:

94015x

Page 22: Section 4.3: Fermat’s Little Theorem

c. , m = 941.

Solution:

94115x

Page 23: Section 4.3: Fermat’s Little Theorem

Fermat’s Little Theorem can be used to simplify

integers with large exponents if the modulus is

prime. The next example illustrates how this

works.

Page 24: Section 4.3: Fermat’s Little Theorem

Example 6: Solve the equation .

Solution:

79 MOD 10782x

Page 25: Section 4.3: Fermat’s Little Theorem