Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 8 Introduction To Number Theory. Prime Numbers Prime numbers only have divisors of 1 and Prime numbers only have divisors of 1 and self. self.

Similar presentations


Presentation on theme: "Chapter 8 Introduction To Number Theory. Prime Numbers Prime numbers only have divisors of 1 and Prime numbers only have divisors of 1 and self. self."— Presentation transcript:

1 Chapter 8 Introduction To Number Theory

2 Prime Numbers Prime numbers only have divisors of 1 and Prime numbers only have divisors of 1 and self. self. Prime numbers cannot be written as a Prime numbers cannot be written as a product of other numbers. product of other numbers. An integer p>1 is a prime number if and only if its only divisors are ±1 and ±p. An integer p>1 is a prime number if and only if its only divisors are ±1 and ±p. For example:- For example:- 2,3,5,7,11,13,17,19,23,29,31,37 are some prime numbers 2,3,5,7,11,13,17,19,23,29,31,37 are some prime numbers

3 An Integer Representation  Any integer a>1 can be represented in prime factorization as a=p 1 a1.p 2 a2 ……….p n an a=p 1 a1.p 2 a2 ……….p n an Where p 1


4 An Integer Representation General Form:- If P is the set of all prime If P is the set of all prime numbers, then any integer can be uniquely written in the general form as a = ∏ p a p where each ap≥0 pεP pεP For example:- 3600=2 4 ×3 2 ×5 2 a=3600, p=2,3,5 a 2 =4 a 3 =2 and a 5 =2 a 2 =4 a 3 =2 and a 5 =2

5 An Integer Representation (cont.) The integer 12 represented as by {a 2 =2,a 3 =1} The integer 18 represented as by {a 2 =1,a 3 =2} Multiplication :- Multiplication of two numbers is equivalent to adding the corresponding exponents: 12×18=216 12×18=216Or a 2 =2+1=3 a 3 =1+2=3 a 2 =2+1=3 a 3 =1+2=3 2 3 x3 3 = x3 3 =216

6 Division:- Any integer of the form p k can be divided only by an integer that is of a lesser or equal power of the same prime number, p j with j≤k. a|b a p ≤ b p for all p For Example:- a=24 b=72 and 24|72 24=2 3 ×372=2 3 ×3 2 a 2 =3=b 2 a 3 =1≤2=b 3

7 Greatest Common Divisor (GCD):- 300= 2 × 2 × 3 × 5 × 5 300= 2 2 × 3 1 × = 2 × 3 × 3 × 5OR 90= 2 1 × 3 2 × = 2 × 3 × 3 × 5OR 90= 2 1 × 3 2 × 5 1 GCD=2 × 3 × 5 = 30 GCD=2 1 × 3 1 × 5 1 = 30 In general k=gcd(a,b)k p =min(a p,b p ) for all p Problem:- To find prime factors of a large number is not so simple. To find prime factors of a large number is not so simple. Therefore above methods are less applied for large Therefore above methods are less applied for large prime numbers. prime numbers.

8 Fermat’s Theorem Also called Fermat’s little theorem. Statement:- If ‘p’ is a prime, and ‘a’ is a Positive Integer not divisible by p, then a p-1 ≡ 1 mod p For Example: a = 7, p = 19 Fermat’s Little Theorem: ≡ 1 mod ≡ 1 mod 19

9 Fermat’s Theorem Show that: 7 18 ≡ 1 mod 19 As 7 18 = 7 2 x 7 4 x 7 4 x = 49 ≡ 11 mod ≡ 121 ≡ 7 mod ≡ 49 ≡ 11 mod 19 So: (11 x 7 x 7 x 11) mod 19 = [(77 mod 19) x(77 mod 19)] mod 19 ≡ 1 mod 19

10 Fermat’s Theorem Alternative form of Fermat’s theorem:- If ‘p’ is prime and ‘a’ is any positive integer not divisible by ‘p’, then a p ≡a mod p For Example:- 1.p = 5, a = 3, 3 5 = 243 ≡3 mod 5 2.p = 5, a = 10,10 5 = ≡10 mod 5 ≡0 mod 5

11 Euler’s Totient Function ø(n) By doing arithmetic modulo with n By doing arithmetic modulo with n Complete set of residues is: {0,1,2,......n-1} Complete set of residues is: {0,1,2,......n-1} Set of residues is those numbers (residues) which are relatively prime to n. Set of residues is those numbers (residues) which are relatively prime to n. For Example:- n=10 Complete set of residues is {0,1,2,3,4,5,6,7,8,9} Set of relatively prime is {1,3,7,9} Therefore ø(n) is the number of positive integers less than n and relatively prime to n.

12 Euler’s Totient Function ø(n) Example:- 1. ø(37)= ? 2. ø(35)= ? 1. As 37 is prime, therefore all positive integers from 1 to 36 are relatively prime to 37. ø(37)= 36 It shows that for a prime number ‘n’ ø(n)= n-1 2. As 35 is not prime, therefore list of positive integers which are relatively prime to 35. 1,2,3,4,6,8,9,11,12,13,16,17,18,19,22,23,24,25,26,27,29,31,32,33,34

13 Euler’s Totient Function ø(n) There are 24 numbers in the list, so ø(35)=24 ø(35) = ø(7 5) ø(35) = ø(7 x 5) = ø(7) ø(5) = ø(7) x ø(5) = (7 - 1) (5 - 1)=6 4=24 = (7 - 1) x (5 - 1)=6 x 4=24 Therefore if n=pq, where p and q are prime numbers, with pq. Then ø(n) = ø(pq) = ø(p) ø(q) ø(n) = ø(pq) = ø(p) x ø(q) = (p – 1) (q – 1 ) = (p – 1) x (q – 1 )

14 Some values of ø(n) nø(n)nø(n)nø(n)

15 Euler's Theorem Euler’s theorem states that for every ‘a’ and ‘n’ that are relatively prime: a ø(n) 1mod n a ø(n) ≡ 1mod nExamples:- (i).a=3;n=10;ø(10)=4 3 4 = 81 = 1 mod = 81 = 1 mod 10 (ii).a=2;n=11;ø(11)= = 1024 = 1 mod 11

16 Testing For Primality Testing For Primality In a number of cryptographic algorithms use In a number of cryptographic algorithms use very large prime numbers are taken randomly. To find out a large prime number is difficult tasks. To find out a large prime number is difficult tasks. Divide by all numbers (primes) in turn less than the square root of the number is only useful for small numbers. Divide by all numbers (primes) in turn less than the square root of the number is only useful for small numbers. For that reason use Miller and Rabin algorithm to find out a large prime number. For that reason use Miller and Rabin algorithm to find out a large prime number.

17 Miller and Rabin Algorithm A test based on Fermat’s Theorem. A test based on Fermat’s Theorem. TEST (n) 1.Find integers k, q, k > 0, q odd, so that (n–1)=2 k q 2. Select a random integer a, 1

18 Miller and Rabin Algorithm Example # 1:- For prime number n= 29n – 1=28=2 2 (7)=2 k q Let us try a=5a q mod n = mod 29 = 28(No result) In next step:- a 2 j q mod n = n mod 29=28(inconclusive) If test is perform for all integer ‘a’ from 1 to 28, get same inconclusive result, which shows that n=29 is prime number.

19 Miller and Rabin Algorithm Example # 2:- For composite number n=13 7=221 For composite number n=13 x 7=221 n – 1=220=2 2 (55)=2 k q Let us try a=21a q mod n = mod 29 = 200(No result) In next step:- a 2 j q mod n = n mod 29=220(inconclusive) which shows that n=221 is maybe prime number. In fact,of the 220 integer from 1 to 220,six of integer return an inconclusive result (1,21,47,174,200,220)

20 Probabilistic Considerations If Miller and Rabin algorithm returns “composite” the number is definitely not prime.If Miller and Rabin algorithm returns “composite” the number is definitely not prime. Otherwise is a primeOtherwise is a prime Fail to detects that ‘n’ is not prime is < ¼Fail to detects that ‘n’ is not prime is < ¼ Hence if repeat test with different random ‘a’ then chance n is prime after t tests is:Hence if repeat test with different random ‘a’ then chance n is prime after t tests is: Probability (n prime after t tests) = 1-4 -tProbability (n prime after t tests) = 1-4 -t For t=10 this probability is > For t=10 this probability is >

21 Prime Distribution Prime number theorem states that primes occur roughly every (ln n) integers. Prime number theorem states that primes occur roughly every (ln n) integers. Since can immediately ignore evens and multiples of 5, in practice only need test 0.4 ln(n) numbers of size n before locate a prime. Since can immediately ignore evens and multiples of 5, in practice only need test 0.4 ln(n) numbers of size n before locate a prime. For example,if a prime on the order of magnitude of were sought, then about 0.4ln(2 200 )=55 trials are need to find a prime. For example,if a prime on the order of magnitude of were sought, then about 0.4ln(2 200 )=55 trials are need to find a prime. This is only the “average” sometimes primes are close together, at other times are quite far apart. This is only the “average” sometimes primes are close together, at other times are quite far apart.

22 Chinese Remainder Theorem Chinese Remainder Theorem used to speed up Chinese Remainder Theorem used to speed up modulo computations Working modulo a product of numbers Working modulo a product of numbers e.g.mod M = m 1 m 2 ……m k Chinese Remainder theorem lets us work in each moduli m i separately. Chinese Remainder theorem lets us work in each moduli m i separately. since computational cost is proportional to size, this is faster than working in the full modulus M. since computational cost is proportional to size, this is faster than working in the full modulus M.

23 Chinese Remainder Theorem IfA↔(a 1,a 2,……,a k )B ↔(b 1,b 2,……,b k ) then (A+B) mod M ↔((a 1 +b 1 )modm 1,…,(a k +b k )modm k ) (A-B) mod M ↔((a 1 -b 1 )modm 1,…,(a k -b k )modm k ) (A×B) mod M ↔((a 1 ×b 1 )modm 1,…,(a k ×b k )modm k ) c i = M i ×(M i -1 mod m i ) for 1≤i ≤k k A ( ∑ a i c i ) mod M A ≡ ( ∑ a i c i ) mod M i=1 i=1

24 Chinese Remainder Theorem Example:- To represent 973 mod 1813 as a pair of numbers mod 37 and 49 as; m 1 =37,m 2 =49M=1813,A=973 M 1 =49,M 2 =37 M 1 -1 =34 mod m 1,M 2 -1 =4 mod m mod 37 = mod 49 = is represented as (11,42)

25 Chinese Remainder Theorem To add 678 to 973:- To add 678 to 973:- 973 ↔(973 mod 37,973 mod 49)=(11,42) 678 ↔(678 mod 37,678 mod 49)=(12,41) (11+12) mod 37,(42+41) mod 49=(23,34) To Check the result:- To Check the result:- (23,34)↔(a 1 M 1 M a 2 M 2 M 2 -1 ) mod M =[(23)(49)(34)+(34)(37)(4)] mod 1813 =43350 mod 1813 =1651 ( ) mod 1813=1651

26 Primitive Roots According to Euler’s theorem:- a ø(n) mod n=1 According to Euler’s theorem:- a ø(n) mod n=1 Consider a m mod n=1asGCD(a,n)=1 Consider a m mod n=1asGCD(a,n)=1 must exist for m= ø(n) but may be smaller.must exist for m= ø(n) but may be smaller. once powers reach m, cycle will repeat.once powers reach m, cycle will repeat. If smallest is m= ø(n) then a is called a primitive root. If smallest is m= ø(n) then a is called a primitive root. If p is prime, then successive powers of a "generate" the group mod p, e.g. for prime number 19; its primitive root are 2,3,10,13,14 and 15. If p is prime, then successive powers of a "generate" the group mod p, e.g. for prime number 19; its primitive root are 2,3,10,13,14 and 15. These are useful but relatively hard to find. These are useful but relatively hard to find.

27


Download ppt "Chapter 8 Introduction To Number Theory. Prime Numbers Prime numbers only have divisors of 1 and Prime numbers only have divisors of 1 and self. self."

Similar presentations


Ads by Google