CNS2010handout 8 :: introduction to number theory1 computer and network security matt barrie.

Slides:



Advertisements
Similar presentations
Cryptography and Network Security
Advertisements

CSE331: Introduction to Networks and Security Lecture 19 Fall 2002.
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.
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.
Notation Intro. Number Theory Online Cryptography Course Dan Boneh
7. Asymmetric encryption-
Great Theoretical Ideas in Computer Science.
Session 4 Asymmetric ciphers.
1 Chapter 7– Introduction to Number Theory Instructor: 孫宏民 Room: EECS 6402, Tel: , Fax :
Cryptography and Network Security Chapter 4
Cryptography and Network Security Chapter 4 Fourth Edition by William Stallings.
1 Cryptosystems Based on Discrete Logarithms. 2 Outline [1] Discrete Logarithm Problem [2] Algorithms for Discrete Logarithm –A trivial algorithm –Shanks’
6/20/2015 5:05 AMNumerical Algorithms1 x x1x
Discrete Log 1 Discrete Log. Discrete Log 2 Discrete Logarithm  Discrete log problem:  Given p, g and g a (mod p), determine a o This would break Diffie-Hellman.
CS470, A.SelcukPublic Key Cryptography1 CS 470 Introduction to Applied Cryptography Instructor: Ali Aydin Selcuk.
Chapter 4 – Finite Fields Introduction  will now introduce finite fields  of increasing importance in cryptography AES, Elliptic Curve, IDEA, Public.
CSE 321 Discrete Structures Winter 2008 Lecture 8 Number Theory: Modular Arithmetic.
Lecture 3.2: Public Key Cryptography II CS 436/636/736 Spring 2012 Nitesh Saxena.
Chapter 8 – Introduction to Number Theory Prime Numbers
Introduction to Computer and Network Security Iliano Cervesato 2 September 2008 – Public-key Encryption.
1 CIS 5371 Cryptography 8. Asymmetric encryption-.
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
The RSA Algorithm Rocky K. C. Chang, March
Chapter 9 Mathematics of Cryptography Part III: Primes and Related Congruence Equations Copyright © The McGraw-Hill Companies, Inc. Permission required.

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.
Research on the Discrete Logarithm Problem Wang Ping Meng Xuemei
Great Theoretical Ideas in Computer Science.
Prelude to Public-Key Cryptography Rocky K. C. Chang, February
Introduction to Algorithms Second Edition by Cormen, Leiserson, Rivest & Stein Chapter 31.
Modular Arithmetic with Applications to Cryptography Lecture 47 Section 10.4 Wed, Apr 13, 2005.
Basic Number Theory Divisibility Let a,b be integers with a≠0. if there exists an integer k such that b=ka, we say a divides b which is denoted by a|b.
Chapter 4 – Finite Fields
Public key ciphers 2 Session 6.
Data Security and Encryption (CSE348) 1. Lecture # 12 2.
Research on the Discrete Logarithm Problem Wang Ping Meng Xuemei
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.
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.
Lecture 6.1: Misc. Topics: Number Theory CS 250, Discrete Structures, Fall 2011 Nitesh Saxena.
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)
Elliptic Curves Number Theory and Cryptography. A Pile of Cannonballs A Square of Cannonballs.
11 RSA Variants.  Scheme ◦ Select s.t. p and q = 3 mod 4 ◦ n=pq, public key =n, private key =p,q ◦ y= e k (x)=x (x+b) mod n ◦ x=d k (y)=  y mod n.
Ref: Pfleeger96, Ch.31 Properties of Arithmetic Reference: Pfleeger, Charles P., Security in Computing, 2nd Edition, Prentice Hall, 1996.
Lecture 3.1: Public Key Cryptography I CS 436/636/736 Spring 2015 Nitesh Saxena.
15-499Page :Algorithms and Applications Cryptography II – Number theory (groups and fields)
9.1 Primes and Related Congruence Equations 23 Sep 2013.
1 Diffie-Hellman (Key Exchange) Protocol Rocky K. C. Chang 9 February 2007.
Great Theoretical Ideas in Computer Science.
1 Diffie-Hellman (Key Exchange) Protocol Rocky K. C. Chang 9 February 2007.
Ch04-Number Theory and Cryptography 1. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic.
Introduction to Cryptography Hyunsung Kim, PhD University of Malawi, Chancellor College Kyungil University February, 2016.
Cryptography and Network Security Third Edition by William Stallings Lecture slides by Lawrie Brown.
Number Theory Lecture 1 Text book: Discrete Mathematics and its Applications, 7 th Edition.
1 The RSA Algorithm Rocky K. C. Chang February 23, 2007.
Fuw-Yi Yang1 Textbook: Introduction to Cryptography 2nd ed. By J.A. Buchmann Chap 1 Integers Department of Computer Science and Information Engineering,
Discrete Math II Howon Kim
B504/I538: Introduction to Cryptography
Advanced Algorithms Analysis and Design
Numerical Algorithms x x-1 Numerical Algorithms
Introduction to Number Theory
Computer Security Modular Arithmetic November 12, 2018
Number Theory and Euclidean Algorithm
刘振 上海交通大学 计算机科学与工程系 电信群楼3-509
Cryptography Lecture 16.
Presentation transcript:

CNS2010handout 8 :: introduction to number theory1 computer and network security matt barrie

CNS2009handout 8 :: introduction to number theory2 introduction to number theory Motivation: –To understand the security of Diffie-Hellman –To understand asymmetric crypto (e.g. RSA) –Slides 1..9 are background Notation: Z the set of all integers Z + the set of all non-negative integers a|ba divides b i.e. there exists c є Z such that b=ac -3|18, since 18 = (-3)(-6) 173|0, since 0 = (173)(0) p, qwill be reserved for prime numbers The prime decomposition of n є Z + is n = Π p i ei where e i є Z + –in other words, n = p 1 e1 p 2 e2 p 3 e3 … p k ek (note e i can be zero)

CNS2009handout 8 :: introduction to number theory3 groups A Group (G, *) consists of a set G with a binary operation * on G satisfying: –The group operation is associative i.e. a*(b*c) = (a*b)*c –There is an element 1 є G called the identity element a * 1 = 1 * a = a for all a є G –For each element a є G, there exists and element a -1 є G, called the inverse of a, such that a * a -1 = a -1 * a = 1 A Group is commutative, if furthermore: –a * b = b * a for all a, b є G Example: the set of integers Z with addition forms a group –The identity element is 0 and the inverse of a is -a

CNS2009handout 8 :: introduction to number theory4 rings A ring (R, +, x) consists of a set R with two binary operations arbitrarily denoted + (addition) and x (multiplication) on R where: –(R, +) is a commutative group –The operation x is associative i.e. a x (b x c) = (a x b) x c –There is a multiplicative identity denoted 1, with 1 ≠ 0 such that 1 x a = a x 1 = a for all a є R –The operation x is distributive over +, that is: a x (b + c) = (a x b) + (a x c) and (b + c) x a = (b x a) + (c x a) The ring is a commutative ring if: –a x b = b x a for all a, b є R Example: the set of integers Z with addition and multiplication forms a commutative ring

CNS2009handout 8 :: introduction to number theory5 fields A field is a commutative ring in which all non-zero elements have inverses. Fact: Z p is only a field if p is a prime number. For example, Z n = where n is a composite (product of two primes) is not a field (it is a ring). e.g. Z 6 = 2 x 3 = 0 (mod 6) 2 -1 does not exist so Z 6 is not a field –no element e such that 2 x e = 1 (mod 6)

CNS2009handout 8 :: introduction to number theory6 gcd, lcm The greatest common divisor, gcd(a,b) of a, b є Z is the largest possible integer, d, such that d|a and d|b. –e.g. gcd(12, 18) = 6 The least common multiple, lcm(a,b) of a, b є Z is the smallest integer, m, such that a|m and b|m. –e.g. lcm(12, 18) = 36 In terms of prime factors, if a = Π p i di and b = Π p i ei then gcd(a,b) = p 1 min(d1,e1) p 2 min(d2,e2)... p k min(dk,ek) = Π p i min(di,ei) lcm(a,b) = p 1 max(d1,e1) p 2 max(d2,e2)... p k max(dk,ek) = Π p i max(di,ei)

CNS2009handout 8 :: introduction to number theory7 euclidean algorithm Suppose we wish to find gcd(a, b) with a ≥ b Algorithm: while b ≠ 0 do: set r ← a mod b, a ← b, b ← r return a Example: gcd(4864, 3458): 4864= = = = = = Hence gcd(4864, 3458) = 38

CNS2009handout 8 :: introduction to number theory8 extended euclidean algorithm EEA: extended to find u,v such that gcd(a, b) = ua + vb Algorithm: INPUT: two non-negative integers a, b with a ≥ b OUTPUT: d = gcd(a, b) and integers x, y such that ax + by = d (1) If b = 0 then set d ← a, x ← 1, y ← 0 and return (d, x, y) (2) Set x 2 ← 1, x 1 ← 0, y 2 ← 0, y 1 ← 1 (3) While b > 0 do : q ← floor(a/b), r ← a - qb, x ← x 2 - qx 1, y ← y 2 - qy 1 a ← b, b ← r, x 2 ← x 1, x 1 ← x, y 2 ← y 1, y 1 ← y (4) Set d ← a, x ← x 2, y ← y 2 and return (d, x, y)

CNS2009handout 8 :: introduction to number theory9 finite fields, Zn and Zp Again, Z p = where p is prime is a called a field –In a field we can add, multiply, take inversions, and the commutative and distributive laws hold. If a and b are integers, then a is said to be congruent to b mod p, if p divides (a-b) i.e. p|a-b a ≡ b (mod p) We can say b is a residue of a (mod p) The inverse of a є Z is b є Z such that ab ≡ 1 (mod p) We can find a -1 by noting that gcd(a, p) = 1, since p is prime.

CNS2009handout 8 :: introduction to number theory10 inverses So by the Extended Euclidean Algorithm (EEA) we can find u, v such that ua + vp = 1 therefore ua = -vp + 1 i.e.ua ≡ 1 (mod p) sou (mod p) = a -1 є Z p Again Z n = where n is a composite (product of two or more primes) is a ring. If a є Z n is such that gcd(a, n) = 1, then we say a is relatively prime to n. Then, by the EEA, there exists u є Z (the inverse) where : ua ≡ 1 (mod n)

CNS2009handout 8 :: introduction to number theory11 Z*, Φ (n) Define Z n * = {a є Z n | gcd (a, n) = 1} –i.e. all the integers of Z n relatively prime to n (n is composite) –otherwise known as the reduced set of residues (mod n) –in other words, all the elements which have inverses Since 0 is not є Z n *, Z n * forms a multiplicative group –a,b є Z n * implies ab є Z n * –a є Z n * implies a -1 є Z n * We define Euler’s (“Oiler”) Totient Function Φ (n) as the number of elements in this set Z n * –If p is prime, then Φ (p) = p - 1 –If gcd(m, n) = 1, then Φ (mn) = Φ (m). Φ (n)

CNS2009handout 8 :: introduction to number theory12 finding inverses with euler’s theorem Euler’s theorem states that for any a є Z n –(a is relatively prime to n) a Φ (n) ≡ 1 (mod n) This is Euler’s generalisation of Fermat’s little theorem –If p is prime and a is a positive integer not divisible by p then a p-1 ≡ 1 (mod p) Now finding an inverse a -1 mod n is easy: x = a Φ (n)-1 mod n Example: what is the inverse of 5 (mod 7)? –Since 7 is prime, Φ (n) = 7-1 = 6 –x = mod 7 = 5 5 mod 7 = 3

CNS2009handout 8 :: introduction to number theory13 order, generators An element, a є Z n * has order d if d is the smallest positive integer such that: a d ≡ 1 (mod n) It may be that all of the elements in Z n * can be obtained as powers of a single element, g, called the generator or primitive element of Z n * : Z n * = = If it has a generator, we say Z n * is a cyclic group. It may be shown that Z n * is a cyclic group if and only if n = 2, 4, p a, 2p a for odd primes p

CNS2009handout 8 :: introduction to number theory14 exponentiation in Zn Can be done efficiently with repeat-and-square Algorithm: INPUT: a є Z n and integer 0 ≤ k < n (where k is t-bits in binary = Σ i=0 k i 2 i ) OUTPUT: a k mod n (1) b ← 1. If k = 0 then return (b) (2) A ← a (3) If k 0 = 1 then b ← a (4) for i = 1.. t do A ← A 2 mod n if k i = 1 then b ← A. b mod n (5) return b t

CNS2009handout 8 :: introduction to number theory15 computing in Zp Let p be a large prime (~300 digits or 1024 bits). The following are easy to do in Z p : –Generate a random element. –Addition and multiplication. –Computing g r mod p, even if r is large. –Inverting an element. –Solving linear systems. –Solving polynomial equations of degree d in polynomial time d. Problems believed to be hard: –Let g be a generator of Z p. Given x є Z p find r such that x = g r mod p. –This is known as the discrete log problem.

CNS2009handout 8 :: introduction to number theory16 computing in Zn Let’s now consider Zn where n is instead a large composite (~1024 bits) which is a product of two primes (~512 bits). The following are easy to do in Z n : –Generating a random element. –Addition and multiplication. –Computing g r mod n, even if r is large. –Inverting an element. –Solving linear systems. Problems believed to be hard if the factorisation of n is unknown: –Finding prime factors of n. –Computing the square root (as hard as factoring n). –Solving polynomial equations of degree d.

CNS2009handout 8 :: introduction to number theory17 hard problems in Z n Discrete Log Problem –Let g be a generator of Z n *. –Given x є Z n * find r such that x = g r mod n. –This is known as the discrete log problem. Diffie-Hellman Problem –Let g be a generator of Z n *. –Given x, y є Z n * where x = g a and y = g b, find g ab. –This is known as the Diffie-Hellman problem.

CNS2009handout 8 :: introduction to number theory18 discrete log problem revisited Given: Consider the finite field Z p * = Let g є Z p be the generator, i.e. Z p * = g p-1 ≡ 1 mod p The discrete log problem asks how to find r given g r Example : Z 11 * = –Consider : g = 2, g 2 = 4, g 3 = 8, g 4 = 5, g 5 = 10 = -1 g 6 = 9, g 7 = 7, g 8 = 3, g 9 = 6, g 10 = 1 (thus 2 is a generator) –Now consider g = 3, 3 2 = 9, 3 3 = 5, 3 4 = 4, 3 5 = 1 thus 3 is not a generator of Z 11 * - order 5 not order 10

CNS2009handout 8 :: introduction to number theory19 diffie-hellman key exchange AliceBob p, g, g a (mod p) g b (mod p) Computes g ab (mod p) Eve ??? Only knows p, g, g a, g b

CNS2009handout 8 :: introduction to number theory20 diffie-hellman key exchange Protocol: Consider the finite field Z p * = Let g є Z p be the generator, i.e. Z p * = g p-1 ≡ 1 mod p g and p are public information (1)Alice: Alice chooses a random large integer a є Z p (2)Alice → Bob: Alice sends Bob g a (mod p) (3)Bob: Bob chooses a random large integer b є Z p (4)Bob → Alice: Bob sends Alice g b (mod p) (5)Alice and Bob: compute g ab : Alice computes (g b ) a = g ab (mod p) : Bob computes (g a ) b = g ab (mod p) => Alice and Bob now share secret g ab

CNS2009handout 8 :: introduction to number theory21 strength of diffie-hellman The strength of Diffie-Hellman is based upon two issues: –given p, g, g a, it is difficult to calculate a (the discrete logarithm problem) –given p, g, g a, g b it is difficult to calculate g ab (the Diffie-Hellman problem) –we know that DL → DH but it is not known if DH → DL Essentially, the strength of the system is based on the difficulty of factoring numbers the same size as p.

CNS2009handout 8 :: introduction to number theory22 attacks on discrete log Question: –Given: G=, g n = 1, y = g a where 1≤ a ≤n-1 –Find: a = log g (y) Most obvious algorithm: exhaustive search Algorithm: –Compute g, g 2, g 3, … until we find g a = y (i.e. a) Problem: –computation is O(n) –i.e. slow

CNS2009handout 8 :: introduction to number theory23 attacks on discrete log Question: –Find a = log g (y) Baby-step giant-step (square root) algorithm A time-memory tradeoff of the exhaustive search method. Algorithm: Let m = floor(√n) Create a table containing j, g j (j = 0.. m-1) Sort the table by g j Compute g -m Set γ = y for i = 0.. m-1 1. if γ is in the table then break; 2. Else set γ = γ g -m and loop output a = j + im

CNS2009handout 8 :: introduction to number theory24 example of baby-step giant-step Let p = 113, g = 3 is a generator of Z 113 * of order n= 112 Question: Find log 3 57 : Set m ← floor(√112) = 11 j j mod Now g -1 = 3 -1 mod 113 = 38 as (38. 3) = 1 mod 113 So g -m = mod 113 = 58 Next γ = y g -mi for i = 0, 1, 2 … i γ = i mod Since y g -9m = 3 is in the table (g 1 ), we output a = j +im = = 100 i.e. 57 = or log 3 57 = 100 Baby Step Giant Step

CNS2009handout 8 :: introduction to number theory25 attacks on discrete log Baby-step giant-step is a time-memory tradeoff of the exhaustive search method (which is obviously O(n)). –Requires O( √ n) storage for group elements –Requires O( √ n) multiplications to construct –Requires O( √ n log n) to do sort of table –Loop takes O( √ n) multiplications and O( √ n) table lookups Under the assumption that group multiplication takes longer than log n comparisons –the running time complexity of baby-step giant-step is O( √ n) –the storage complexity is O( √ n) Pollard-rho is another, more efficient attack on DL.

CNS2009handout 8 :: introduction to number theory26 references Handbook of Applied Cryptography –read §1, § , § Stallings –§7