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.

Slides:



Advertisements
Similar presentations
Number Theory Algorithms and Cryptography Algorithms Prepared by John Reif, Ph.D. Analysis of Algorithms.
Advertisements

Cryptography and Network Security Chapter 8 Fifth Edition by William Stallings Lecture slides by Lawrie Brown.
Cryptography and Network Security Chapter 9
Chapter 3 Public Key Cryptography and RSA Lecture slides by Lawrie Brown Modifications by Nguyen Cao Dat.
Cryptography and Network Security Chapter 8 Fourth Edition by William Stallings.
Opening quote. A number of concepts from number theory are essential in the design of public-key cryptographic algorithms, which this chapter will introduce.
1 Lect. 12: Number Theory. Contents Prime and Relative Prime Numbers Modular Arithmetic Fermat’s and Euler’s Theorem Extended Euclid’s Algorithm.
Cryptography and Network Security
Applied Cryptography (Public key) Part I. Let’s first finish “Symmetric Key” before talking about public key John wrote the letters of the alphabet under.
Cryptography and Network Security
Chapter 8 – Introduction to Number Theory. Prime Numbers prime numbers only have divisors of 1 and self –they cannot be written as a product of other.
Computability and Complexity
Having Proofs for Incorrectness
Chapter 8 Introduction to Number Theory. Prime Numbers prime numbers only have divisors of 1 and self –they cannot be written as a product of other numbers.
5.1 Number Theory. The study of numbers and their properties. The numbers we use to count are called the Natural Numbers or Counting Numbers.
Primality Testing Patrick Lee 12 July 2003 (updated on 13 July 2003)
1 Section 2.4 The Integers and Division. 2 Number Theory Branch of mathematics that includes (among other things): –divisibility –greatest common divisor.
Chapter 8 More Number Theory. Prime Numbers Prime numbers only have divisors of 1 and itself They cannot be written as a product of other numbers Prime.
and Factoring Integers (I)
1 Chapter 7– Introduction to Number Theory Instructor: 孫宏民 Room: EECS 6402, Tel: , Fax :
6/20/2015 5:05 AMNumerical Algorithms1 x x1x
Complexity1 Pratt’s Theorem Proved. Complexity2 Introduction So far, we’ve reduced proving PRIMES  NP to proving a number theory claim. This is our next.
and Factoring Integers
Cryptography & Number Theory
Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.
CSE 321 Discrete Structures Winter 2008 Lecture 8 Number Theory: Modular Arithmetic.
Chapter 8 – Introduction to Number Theory Prime Numbers
Cryptography and Network Security Chapter 8. Chapter 8 – Introduction to Number Theory The Devil said to Daniel Webster: "Set me a task I can't carry.
Chapter 8 – Introduction to Number Theory Prime Numbers  prime numbers only have divisors of 1 and self they cannot be written as a product of other numbers.
Topic 18: RSA Implementation and Security
CSE 321 Discrete Structures Winter 2008 Lecture 10 Number Theory: Primality.
The Integers and Division
Prime Numbers Prime numbers only have divisors of 1 and self
Chapter 9 Mathematics of Cryptography Part III: Primes and Related Congruence Equations Copyright © The McGraw-Hill Companies, Inc. Permission required.
Software Security Seminar - 1 Chapter 11. Mathematical Background 발표자 : 안병희 Applied Cryptography.
Cryptography A little number theory Public/private key cryptography –Based on slides of William Stallings and Lawrie Brown.

1 Cryptography and Network Security Third Edition by William Stallings Lecture slides by Lawrie Brown Chapter 4 – Finite Fields.
Information Security and Management 4. Finite Fields 8
Basic Concepts in Number Theory Background for Random Number Generation 1.For any pair of integers n and m, m  0, there exists a unique pair of integers.
YSLInformation Security -- Public-Key Cryptography1 Prime and Relatively Prime Numbers Divisors: We say that b  0 divides a if a = mb for some m, where.
Fall 2002CS 395: Computer Security1 Chapters 4 and 8: The Mathematics Required for Public Key Cryptography In case you’re beginning to worry that this.
CSE 311: Foundations of Computing Fall 2014 Lecture 12: Primes, GCD.
CS/ECE Advanced Network Security Dr. Attila Altay Yavuz
9/22/15UB Fall 2015 CSE565: S. Upadhyaya Lec 7.1 CSE565: Computer Security Lecture 7 Number Theory Concepts Shambhu Upadhyaya Computer Science & Eng. University.
6.3 Primality Testing. p2. (1) Prime numbers 1. How to generate large prime numbers? (1) Generate as candidate a random odd number n of appropriate size.
Week 4 - Wednesday.  What did we talk about last time?  Finished DES  AES.
Introduction to Number Theory
Primality Testing. Introduction The primality test provides the probability of whether or not a large number is prime. Several theorems including Fermat’s.
9.1 Primes and Related Congruence Equations 23 Sep 2013.
Lecture 2-3 Basic Number Theory and Algebra. In modern cryptographic systems, the messages are represented by numerical values prior to being encrypted.
MA/CSSE 473 Day 09 Modular Division Revisited Fermat's Little Theorem Primality Testing.
CS480 Cryptography and Information Security
Public Key Encryption Major topics The RSA scheme was devised in 1978
Introduction to Number Theory
Mathematics of Cryptography
CSE565: Computer Security Lecture 7 Number Theory Concepts
Numerical Algorithms x x-1 Numerical Algorithms
Cryptography and Network Security
Introduction to Number Theory
Cryptography and Network Security Chapter 8
Number Theory (Chapter 7)
Cryptography and Network Security
Prime and Relatively Prime Numbers
Cryptography and Network Security
Introduction to Cryptography
Mathematical Background for Cryptography
Patrick Lee 12 July 2003 (updated on 13 July 2003)
Clements MAΘ October 30th, 2014
Lecture 2-3 Basic Number Theory and Algebra
Presentation transcript:

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. 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

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 <p 2 <……..<p n are prime numbers and ai (i=1,2,3……n) is a positive integer. For example:- 91=7× =7×11 2 ×13 91=7× =7×11 2 × =2 4 ×3 2 × =2 4 ×3 2 ×5 2

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

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

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

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.

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

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

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

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.

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

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 )

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

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

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.

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<a<n–1 3. if a q mod n = 1 then return (“inconclusive"); 4. for j = 0 to k – 1 do 5. if a 2 j q mod n = n-1 then return(" inconclusive ") 6. return ("composite")

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.

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)

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 >

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.

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.

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

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)

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

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.