1 Chapter 7– Introduction to Number Theory Instructor: 孫宏民 Room: EECS 6402, Tel:03- 5742968, Fax : 886-3-572-3694.

Slides:



Advertisements
Similar presentations
Cryptography and Network Security Chapter 8 Fifth Edition by William Stallings Lecture slides by Lawrie Brown.
Advertisements

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
Chapter 4 Finite Fields. Introduction of increasing importance in cryptography –AES, Elliptic Curve, IDEA, Public Key concern operations on “numbers”
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
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.
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.
Primality Testing Patrick Lee 12 July 2003 (updated on 13 July 2003)
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.
CNS2010handout 8 :: introduction to number theory1 computer and network security matt barrie.
and Factoring Integers (I)
Cryptography and Network Security Chapter 4
Cryptography and Network Security Chapter 4 Fourth Edition by William Stallings.
and Factoring Integers
Chapter 4 – Finite Fields Introduction  will now introduce finite fields  of increasing importance in cryptography AES, Elliptic Curve, IDEA, Public.
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.
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.

Module :MA3036NI Cryptography and Number Theory Lecture Week 7
FINITE FIELDS 7/30 陳柏誠.
CPSC 3730 Cryptography and Network Security
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
Cryptography and Network Security Introduction to Finite Fields.
Prelude to Public-Key Cryptography Rocky K. C. Chang, February
Chapter 4 – Finite Fields
Data Security and Encryption (CSE348) 1. Lecture # 12 2.
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.
CS/ECE Advanced Network Security Dr. Attila Altay Yavuz
Chapter 3 Public Key Cryptography MSc. NGUYEN CAO DAT Dr. TRAN VAN HOAI.
Information Security Lab. Dept. of Computer Engineering 87/121 PART I Symmetric Ciphers CHAPTER 4 Finite Fields 4.1 Groups, Rings, and Fields 4.2 Modular.
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.
Cryptography and Network Security Chapter 4. Introduction  will now introduce finite fields  of increasing importance in cryptography AES, Elliptic.
Tuesday’s lecture: Today’s lecture: One-way permutations (OWPs)
Pertemuan #5 Pengantar ke Number Theory Kuliah Pengaman Jaringan.
15-499Page :Algorithms and Applications Cryptography II – Number theory (groups and fields)
9.1 Primes and Related Congruence Equations 23 Sep 2013.
Cryptography and Network Security Chapter 4 Fifth Edition by William Stallings Lecture slides by Lawrie Brown.
Cryptography Lecture 14 Arpita Patra © Arpita Patra.
CS480 Cryptography and Information Security
Cryptography and Network Security Third Edition by William Stallings Lecture slides by Lawrie Brown.
Discrete Math II Howon Kim
Introduction to Number Theory
CSE565: Computer Security Lecture 7 Number Theory Concepts
Topic 12: Number Theory Basics (2)
Numerical Algorithms x x-1 Numerical Algorithms
Number-Theoretic Algorithms (UNIT-4)
Cryptography and Network Security
Introduction to Number Theory
Cryptography and Network Security Chapter 8
Number Theory (Chapter 7)
Cryptography and Network Security
Cryptography and Network Security
刘振 上海交通大学 计算机科学与工程系 电信群楼3-509
Mathematical Background for Cryptography
Presentation transcript:

1 Chapter 7– Introduction to Number Theory Instructor: 孫宏民 Room: EECS 6402, Tel: , Fax :

2 Prime Numbers prime numbers only have divisors of 1 and self –they cannot be written as a product of other numbers –note: 1 is prime, but is generally not of interest eg. 2,3,5,7 are prime, 4,6,8,9,10 are not prime numbers are central to number theory list of prime number less than 200 is:

3 Prime Factorisation to factor a number n is to write it as a product of other numbers: n=a × b × c note that factoring a number is relatively hard compared to multiplying the factors together to generate the number the prime factorisation of a number n is when its written as a product of primes –eg. 91=7×13 ; 3600=2 4 ×3 2 ×5 2

4 Relatively Prime Numbers & GCD two numbers a, b are relatively prime if have no common divisors apart from 1 –eg. 8 & 15 are relatively prime since factors of 8 are 1,2,4,8 and of 15 are 1,3,5,15 and 1 is the only common factor conversely can determine the greatest common divisor by comparing their prime factorizations and using least powers –eg. 300=2 1 ×3 1 ×5 2 18=2 1 ×3 2 hence GCD(18,300)=2 1 ×3 1 ×5 0 =6

5 Fermat's Theorem a p-1 mod p = 1 –where p is prime and gcd(a,p)=1 also known as Fermat’s Little Theorem useful in public key and primality testing

6 Euler Totient Function ø(n) when doing arithmetic modulo n complete set of residues is: 0..n-1 reduced set of residues is those numbers (residues) which are relatively prime to n –eg for n=10, –complete set of residues is {0,1,2,3,4,5,6,7,8,9} –reduced set of residues is {1,3,7,9} number of elements in reduced set of residues is called the Euler Totient Function ø(n)

7 Euler Totient Function ø(n) to compute ø(n) need to count number of elements to be excluded in general need prime factorization, but –for p (p prime) ø(p) = p-1 –for p.q (p,q prime) ø(p.q) = (p-1)(q-1) eg. –ø(37) = 36 –ø(21) = (3–1)×(7–1) = 2×6 = 12

8 Euler's Theorem a generalisation of Fermat's Theorem a ø(n) mod N = 1 –where gcd(a,N)=1 eg. –a=3;n=10; ø(10)=4; –hence 3 4 = 81 = 1 mod 10 –a=2;n=11; ø(11)=10; –hence 2 10 = 1024 = 1 mod 11

9 Primality Testing often need to find large prime numbers traditionally sieve using trial division –ie. divide by all numbers (primes) in turn less than the square root of the number –only works for small numbers alternatively can use statistical primality tests based on properties of primes –for which all primes numbers satisfy property –but some composite numbers, called pseudo-primes, also satisfy the property

10 Miller Rabin Algorithm a test based on Fermat’s Theorem algorithm is: TEST (n) is: 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 (“maybe prime"); 4. for j = 0 to k – 1 do 5. if ( a 2 j q mod n = n-1 ) then return(" maybe prime ") 6. return ("composite")

11 Probabilistic Considerations if Miller-Rabin returns “composite” the number is definitely not prime otherwise is a prime or a pseudo-prime chance it detects a pseudo-prime is < ¼ hence if repeat test with different random a then chance n is prime after t tests is: –Pr(n prime after t tests) = 1-4 -t –eg. for t=10 this probability is >

12 Prime Distribution 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 –note this is only the “average” sometimes primes are close together, at other times are quite far apart

13 Algebraic System Binary Operation: Given a nonempty set S and a function op : S×S  S, then op is a binary operation on S. Examples: S= N and op = × :the multiple of integer S= N and op = +: the addition of integer. Algebratic Systems: (S, op 1, op 2, …, op n ), where S is a nonenmpty set and there are at least one binary operation on S. Examples: (R, +, ×) and (Z, +, ×)

14 Properties of Algebratic Systems –Closure: a op b  S, where a and b  S. –Associative: (a op b) op c= a op (b op c) for (S, op), where a, b, and c  S. –Communicative: a op b = b op a for (S, op) for a and b  S. –(Z, -) have no communicative property. –Identity: For (S, op),  e  S,  a  S, such that a op e= e op a= a. –Example: For (Z, +), e=0, for (Z, ×), e= 1. –Inverses: For (S, op),  a  S,  b  S, such that a op b = b op a = e. –Symbol : a -1 or -a.

15 –Example: For (Z, +), the inverse of a is -a. –Example: For (R/{0}, ×), the inverse of a is a -1 while, for (Z, ×), there is no inverse for any integer. –Distribution: For (S, +, *), a*(b+c)= a*b+a*c, where a, b, and c  S. –Semigroup (G,*): An algebratic system (G, *) with the following properties: Closure, association, and an identity. –Theorem: For a semigroup (G, *), the identity is unique.

16 Groups (G, *) : A semigroup (G, *) with inverses. Examples:(Z, +), (R/{0}, *) are groups. Abelian (Commutative) Groups: the group with communitative property Theorem: For a group (G, *), the inverse of an element in G is unique. Field (F, +, *): (F, +) is a commutative group. (F, *) is a semigroup and (F-{0}, *) is a commutative group, where 0 is the identity for the operation +.

17 Finite Fields Finite Group (G, *): A group (G, *) with finite elements in G. Example: ({0, 1, …, N-1}, +N) is a finite group, where N is an integer. Cyclic Group (G, *): For a group (G, *), there exists an element a such that G= {an|n  Z}, where an =a*a* …*a (n-1 times). a:primitive root (with the order n=|G|). Example: ({1, …, 6}, *7) is a cyclic group with the primitive root 3. [{3, 2, 6, 4, 5, 1}, & order= 6]

18 Generator with order m: a m =1. Finite Fields: A field (F, +, *) with finite elements in F. Example:GF(P)= ({0, 1, …, P-1}, +P, *P) for a prime number P. [The first finite fields].

19 Some Famous Finite Fields [P is a prime number] GF(P) or ZP. GF(Pn): Given an irreducible polynomial Q(x) of degree n over GF(P). GF(2n) for P= 2. Example: Q(x)= x 3 +x+1 over GF(2) (x+1)+ (x)= 1. (x+1)*x 2 = x 2 +x+1.

20 Congruences Given integers a, b, and n  0, a, is congruent to b modulo n, written a  b mod n if and only if a  b = kn for some integer k. Ex. 41  93 mod  10 mod8.

21 If a  b mod n, then b is called a residue of a modulo n (conversely, a is a residue of b modulo n). A set of n integers {r 1, …, r n } is called a complete set of residues modulo n if, for every integer a, there is exactly one r i in the set such that a  r i mod n. For any modulus n, the set of integers {0, 1,…, n  1} forms a complete set of residues modulo n.

22 Computing Inverses Unlike ordinary integer arithmetic, modular arithmetic sometimes permits the computation of multiplicative inverse That is, given an integer a in the range [0, n  1], it may be possible to find a unique integer x in the range [0, n  1] such that ax mod n = 1. Ex. 3 and 7 are multiplicative inverses mod 10 because 21 mod 10 = 1. Thm. If gcd(a, n) = 1, then (ai mod n)  (aj mod n) for each i, j such that 0  i < j < n.

23 This property implies that each ai mod n (i = 0,..., n  1) is a distinct residue mod n, and that the set {ai mod n} i=0,..., n  1 is a permutation of the complete set of residues {0,..., n  1}. This property does not hold when a and n have a common factor. If gcd(a, n) = 1, then there exists an integer x, 0 < x < n, such that ax mod n = 1.

24 Ex. n = 5 and a = 3: 3  0 mod 5 = 0 3  1 mod 5 = 3 3  2 mod 5 = 1 3  3 mod 5 = 4 3  4 mod 5 = 2. Ex. n = 4 and a = 2: 2  0 mod 4 = 0 2  1 mod 4 = 2 2  2 mod 4 = 0 2  3 mod 4 = 2.

25 Solving for Inverse Euler's generalization of Fermat's theorem gives us an algorithm for solving the equation ax mod n = 1, where gcd(a, n) = 1. Since a  (n) mod n = 1, we may compute x as ax  a  (n), or x = a  (n)  1 mod n. If n is prime, this is simply x = a (n  1)  1 mod n = a n  2 mod n.

26 Ex. Let a = 3 and n = 7. Then x = 3 5 mod 7 = 5. Ex. Let a = 2 and n = 15. Then x = 2 7 mod 15 = 8. With this approach, to compute x, you have to know  (n).

27 Another Approach x can also be computed using an extension of Euclid's algorithm for computing the greatest common divisor. This is more suitable for computers to do. Euclid's algorithm for computing greatest common divisor : gcd(a, n) g 0  n g 1  a i  1 while g i  0 g i+1  g i  1 mod g i i  i + 1 return g i  1

28 Extended Euclid's Algorithm Extended Euclid's algorithm for computing inverse (loop invariant: g i = u i n + v i a): inv(a, n) g 0  n; g 1  a; u 0  1; v 0  0; u 1  0; v 1  1; i  1 while g i  0 y  g i  1 div g i g i+1  g i  1  y  g i u i+1  u i  1  y  u i v i+1  v i  1  y  v i i  i + 1 x  v i  1 if x  0 return x else return x + n

29 Example Ex. To solve 3x mod 7 = 1 using the algorithm, we have Because v 2 =  2 is negative, the solution is x =  = 5. igigi uiui vivi y 22 3 30

30 Chinese Remainder Theorem used to speed up modulo computations working modulo a product of numbers –eg. mod M = m 1 m 2..m k 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

31 Chinese Remainder Theorem can implement CRT in several ways to compute (A mod M) can firstly compute all (a i mod m i ) separately and then combine results to get answer using:

32 Example Ex. Solve the equation "3x mod 10 = 1". Since 10 = 2  5, d 1 = 2 and d 2 = 5. We first find solutions x 1 and x 2, as follows: 3x mod 2 = 1 mod 2 = 1  x 1 = 1 3x mod 5 = 1 mod 5 = 1  x 2 = 2 Then we apply the Chinese Remainder Theorem to find a common solution x to the equations:

33 x mod 2 = x 1 = 1 x mod 5 = x 2 = 2. We find y 1 and y 2 satisfying (10/2) y 1 mod 2 = 1  y 1 = 1 (10/5) y 2 mod 5 = 1  y 2 = 3 Thus, we have x= ((10/2) y 1 x 1 + (10/5) y 2 x 2 ) mod 10 = (5  1   3  2) mod 10 = 7.

34 Primitive Roots from Euler’s theorem have a ø(n) mod n=1 consider a m mod n=1, GCD(a,n)=1 –must exist for m= ø(n) but may be smaller –once powers reach m, cycle will repeat 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 these are useful but relatively hard to find

35 Discrete Logarithms or Indices the inverse problem to exponentiation is to find the discrete logarithm of a number modulo p that is to find x where a x = b mod p written as x=log a b mod p or x=ind a,p (b) if a is a primitive root then always exists, otherwise may not –x = log 3 4 mod 13 (x st 3 x = 4 mod 13) has no answer –x = log 2 3 mod 13 = 4 by trying successive powers whilst exponentiation is relatively easy, finding discrete logarithms is generally a hard problem