# Basic elements of number theory

Size: px
Start display at page:

Transcription

1 Cryptography Basic elements of number theory Marius Zimand By default all the variables, such as a, b, k, etc., denote integer numbers. Divisibility a 0 divides b if b = a k for some integer k. Notation a b. Properties 1. a 0 a 0, a a 2. 1 b for all b 3. a b and b c a c 4. a b and a c a (sb + tc), for all integers s and t. Prime Numbers An integer number p > 1 is prime if it is divisible only by 1 and by itself. Examples: 2, 3, 5, 7, 11, 13, 17, 19,... Facts: There are an infinity of prime numbers. Fundamental Theorem of Arithmetic. Each integer has a unique representation as a product of prime numbers. Example: 504 =

2 Prime Number Theorem. Let π(x) denote the number of primes x. For example π(10) = 4. Then π(x) x ln x. The above means that lim x π(x) (x/ ln x) = 1. In fact, it is known that if x 17, then x ln x < π(x) < 1.26 x ln x. Application: Estimate the number of prime numbers with 100 digits. It is π( ) π(10 99 ) ln ln If p is prime and p ab, then p a or p b. Greatest Common Divisor Notation gcd(a, b) or (a, b). It is what the name says it is: we look at the common divisors of a and b, and we pick the largest. Examples: gcd(6, 4) = 2, gcd(9, 14) = 1, we say that 9 and 14 are relatively prime, or co-prime (the numbers have no common divisor other than 1). How to find gcd(a, b)? (1) Easy case: If we can factor a and b into primes. Then we take the common prime divisors at the smallest exponent = =

3 So gcd(1728, 405) = 3 3. (2) If a and b are large, it is very difficult to factor them. We use instead the Euclidean algorithm. First an example. We want gcd(482, 1180) = = = = (last non-zero remainder) 16 = Note the shifts: remainder divisor dividend discard. In general a = q 1 b + r 1 b = q 2 r 1 + r 2 r 1 = q 3 r 2 + r 3. r k 2 = q k r k 1 + r k (last non-zero remainder) r k 1 = q k+1 r k + 0. Then gcd(a, b) = r k. Why is that? The answer is given by the following fact, which is easy to prove. Fact 1 gcd(a, b) = gcd(b, r 1 ). So, gcd(a, b) = gcd(b, r 1 ) = gcd(r 1, r 2 ) =... = gcd(r k 1, r k ) = r k. 3

4 It holds that b > r 1 > r 2 >... > r k, and all the numbers in the sequence are positive integer. Any decreasing sequence of positive integers is finite, so the algorithm will eventually stop. But how fast? How fast is the euclidean algorithm? Fact 2 r 3 < r 1 /2. Proof. Case 1. r 2 (r 1 /2), then we are done because r 3 < r 2. Case 2. r 2 > (r 1 /2). (Recall that r 2 < r 1.) Then q 3 = 1, and r 3 = r 1 q 3 r 2 = r 1 1 r 2 < r 1 (r 1 /2) < (r 1 /2). In a similar way, we can show that r 5 < (r 3 /2), etc. So we have r 1 > 2r 3 > 4r 5 >... > 2 n r 2n+1 (the last odd step). So, 2 n < r 1 r 2n+1 r 1 < b. So n < log 2 (b). Thus the number of steps is 2n + 2 < 2 log 2 (b) + 2 = O(log 2 (b)). Thus the Euclidean Algorithm is very fast: the number of steps is roughly 2* length of b, and each step is essentially just a division. 4

5 Solving linear equation ax + by = d in integers We use the following theorem (stated without proof). Theorem 3 For any integers a and b there are integers x and y such that ax + by = gcd(a, b). How to find x and y? By using the Extended Euclidean algorithm. Let q 1, q 2,..., q n be the sequence of quotients in the Euclidean algorithm. We form the recurrences: x 0 = 0, x 1 = 1, x j = q j 1 x j 1 + x j 2, and y 0 = 1, y 1 = 0, y j = q j 1 y j 1 + y j 2. Then ax n + by n = gcd(a, b). Note: y n is the coefficient of the larger between a and b. In our example (i.e., gcd(482,1180)), we had: q 1 = 2, q 2 = 2, q 3 = 4, q 4 = 3, q 5 = 8. So, we get: x 0 = 0, x 1 = 1, x 2 = 2x 1 + x 0 = 2 x 3 = 2x 2 + x 1 = 5 x 4 = 4x 3 + x 2 = 22 x 5 = 3x 4 + x 3 = 71. 5

6 Similarly, we obtain y 5 = 29. So ( 29) = 2 = gcd(480, 1180). Now, back to the equation ax + by = d. If gcd(a, b) d, then there are no solutions. Else find x and y such that ax + by = gcd(a, b). Then multiply x and y by Modular Arithmetic d gcd(a,b) to obtain x and respectively y. Definition 4 a = b(mod m) if m a b. Example: 32 = 2(mod 5), 12 = 37(mod 7). Equality mod m is an equivalence relation. An equivalence relation R is a binary relation that has the following three properties: For all a in the domain, R(a, a) (reflexivity). For all a, b in the domain, if R(a, b) then R(b, a) (commutativity). For all a, b, c in the domain, if R(a, b) and R(b, c), then R(a, c) (transitivity). If R is an equivalence relation, we can partition its domain into equivalence classes, where we put all the elements that are in the relation R in one class. Thus, we can view the set of numbers that are equal to a modulo m as one single class. Such a class is called a residue class. We can pick a as the representative of that class. In this context, a intuitively denotes not one number but an entire set of numbers. For example, if we work modulo 2, 0 denotes the class of even numbers, and 1 denotes the class of odd numbers. We say that 0 is a representative of the class of even numbers, and 1 is a representative of the class of odd numbers. One nice property is that we can add and multiply such classes by operating with their representatives. 6

7 Thus, to give just an example, one interpretation of the fact that = 0(mod 2) is that (any number in the class of 1) + (any number in the class of 1) = (some number in the class of 0). And, similarly, one interpretation of the fact that 1 0 = 0(mod 2) is that (any number in the class of 1) (any number in the class of 0) = (some number in the class of 0). Or, in other words, to find how much is a + b(mod m) (or a b(mod m)), one can take a representative a of the class that contains a and one representative b of the class that contains b and do the arithmetic operation using the representatives. Integers modulo m can be added and multiplied. In some circumstances (to be discussed later) we can also do division modulo m. For example: = 2(mod 6), = 0(mod 6), = 3(mod 6). We can form the addition table modulo Note that addition modulo 6 is commutative (a+b = b+a). is associative (a+(b+c)) = ((a+b) + c) has a zero element (a+ zero = a) 7

8 each element a has a symmetric element, which is denoted a. These properties are valid for addition modulo m, for any m (not just for m = 6). We can also form the multiplication table modulo Note that multiplication modulo 6 is commutative (a b = b a). is associative (a (b c)) = ((a b) c) has a unity element (a unity = a) Note that not every element a has an inverse element, only 1 and 5 have inverses. In general, Theorem 5 a has an inverse modulo m iff gcd(a, m) = 1. Also note that row i has a period of length 6 gcd(i,6) and the entries on that row are multiples of gcd(i, 6). This is true for any modulo m, not just for m = 6. If the modulo m is a prime number, then all the elements 0 have an inverse. In this case, we can do addition, multiplication, and division and have all the properties of these arithmetic operation (commutativity, assoc., distributivity or factoring-out) we are used to from elementary school. 8

9 Notation: Z m = class of residues modulo m with the operations of + and. In general Z m is a ring (+ has all the good properties, is comm., assoc, has unity element, is distributive with respect to +). If m is prime, then Z m is a field (a field has all the properties of a ring + one extra very important property: every element a, except 0, has an inverse, which is denoted a 1 ; this basically implies that in a field, we can also do division). How to find a 1 (mod m)? Use the extended Euclidean algorithm to find s and t such that as + mt = 1. Then as = 1(mod m), so s = a 1 (mod m). Solving ax = b(mod n) Let d = gcd(a, n). Case 1. d = 1. Then we find a 1 (mod n) (using the extended Euclidean Algorithm), and x = b a 1 (mod n). Example: 5x + 6 = 13(mod 11) 5x = 13 + ( 6) = 7(mod 11) x = (mod 11), 5 1 = 9 So, x = 7 9 = 63 = 8(mod 11). Case 2. If d b, then the equation has no solution. 9

10 Case 3. d b We divide everything by d, and we get the new equation a d x = b d (mod n d ). Note that gcd( a, n ) = 1, so we can solve the new equation as in Case 1. d d So we solve the equation, and we obtain the solution x 0. The solutions of the original equation are Example: 12x = 21(mod 39) gcd(12, 39) = 3, which divides 21. x 0, x 0 + n d, x n d,..., x 0 + (d 1) n d. New equations is (we divide everything by 3): 4x = 7(mod 13) x 0 = 7 (4 1 ) = 7 10 = 5(mod 13). The solutions of the original equation are: 5, 5+13, 5+26, i.e, 5, 18, and 31. The Chinese Remainder Theorem (CRT) CRT is about solving a system of linear equations in modular arithmetic. It is used to represent an integer as a sequence of smaller integers, or to break one congruence into several congruences with smaller moduli. One simple example: If we know how much a number x is mod 42, then it is easy to determine how much it is mod 6 and mod 7. x = 25(mod 42) x = k = 25 + (6k) 7 x = 25(mod 7) = 4(mod 7) x = k = 25 + (7k) 6 x = 25(mod 6) = 1(mod 6). CRT goes the other way: Given the values of x mod 6 and mod 7, it allows us to fnd how much is x mod

11 CRT - the simple form Theorem 6 Suppose gcd(m, n) = 1. Given a, b, the system of equations x = a(mod m) x = b(mod n) has exactly one solution in the range {0, 1,..., mn 1}. For example, consider the system of equations x = 3(mod 7) x = 5(mod 15) The CRT says that there exists such an x and just one such x among the integers {0, 1,..., = 104}. How to find such an x: Case 1. If m and n are small. We list the numbers that are = b(mod n) (in our example, = 5(mod 15)) 5, 20, 35, 50, 65, 80, 95 (next one is 105) Then we take each of the numbers in the list mod m (in our example, mod 7) 5, 6, 0, 1, 2, 3, 4. So the solution is 80. Case 2. If m and n are big. In this case, the above procedure is not efficient, but we can use the same idea. numbers = b(mod n) are of the form b + nk. So we need b + nk = a(mod m) (here the unknown is k). nk = a b(mod m) 11

12 gcd(m, n) = 1, so n 1 (mod m) exists. So, k = (a b) n 1 (mod m). Example: Solve x = 7(mod 12345) x = 3(mod 11111) gcd(12345, 11111) = 1 and (11111) 1 (mod 12345) = So k = 2471(7 3) = 9884(mod 12345). So x = = (mod ). Why is CRT useful? Example: Let s say we need to solve x 2 = 1( mod 35). It is easier to solve modular equations mod a prime number. 35 is not prime, but 35 = 5 7, so 35 is the product of two prime numbers. Then x 2 = 1(mod 5) x 2 = 1(mod 35) x 2 = 1(mod 7) is clear. : (x 2 1) = 0(mod 5), (x 2 1) = 0(mod 7), so (x 2 1) = 0(mod 35) (a number that is a multiple of 5 and 7 has to be a multiple of 35). So now we have two equations instead of one, but both are mod a prime number. Lemma 7 If p is a prime 2, then x 2 = 1( mod p) has only the solutions 1 and 1. Proof. x 2 1 = 0(mod p) (x 1)(x + 1) = 0(mod p), so x 1 = 0(mod p) or x + 1 = 0(mod p) (because p is prime). 12

13 So, x = ±1(mod 5) and x = ±1(mod 7). Now we want to go back to mod 35. For this we need the CRT!. There are 4 cases. x = 1(mod 5), x = 1(mod 7) CRT x = 1(mod 35) x = 1(mod 5), x = 1(mod 7) CRT x = 6(mod 35) x = 1(mod 5), x = 1(mod 7) CRT x = 29(mod 35) x = 1(mod 5), x = 1(mod 7) CRT x = 34(mod 35) (Please do the CRT implication at home, as an exercise.) So x 2 = 1(mod 35) has 4 solutions: 1, 6, 29, 34 (in the interval {0, 1,..., 34}). Chinese Remainder Theorem - general form Let m 1, m 2,..., m k be integers, pairwise relatively prime, i.e. gcd(m i, m j ) = 1 for all i j. For any integers a 1, a 2,..., a k the system of equations x = a 1 (mod m 1 ) x = a 2 (mod m 2 ). x = a k (mod m k ) has solutions, and moreover there exists exactly one solution in the interval {0,... m 1 m 2... m k 1}. Also note that there exists an efficient algorithm that finds the unique solution in the interval {0,... m 1 m 2... m k 1}. 13

14 Modular exponentiation We want to calculate a b (mod n) This is used a lot in crypto - in RSA both encryption and decryption are modular exponentiations. Example: (mod 789). If we first calculate , and then take the mod, we would have to work with numbers that are too large. So we ll take the mod after each multiplication = } 2 2 {{... 2 }. 1233times We can do fewer multiplications, if we do repeated squarings. So we keep on squaring (everything is mod 789). 2 2 = 4, 2 4 = 4 2 = 16, 2 8 = 16 2 = 256, 2 16 = = 49, 2 32 = 49 2 = 34, 2 64 = 367, = 559, = 37, = 589, = 286. Next we note that 1234 = (observe that 1234 = ). Therefore, = = = 481(mod 789). We can always do this - this is the repeated-squaring-with-mod method. Suppose we want a b (mod n), and a, b, n have each 100 digits. So b < = (10 3 ) < (2 10 ) = So b in binary has < 334 bits. Thus, we need less than 334 squarings a, a 2, a 4,... and then less than 334 multiplications between these square numbers. So we do at most = 668 multiplications and modulo reductions. 14

15 Fermat s Little Theorem and Euler Theorem Theorem 8 (Fermat s Theorem.) If p is a prime number and p a, then a p 1 = 1(mod p). Proof. Let S = {1, 2, 3,..., p 1}. Let us consider the function f(x) = a x( mod p), defined for all x S. Note that for all x S, f(x) S, because f(x) cannot be 0 (Proof by contradiction: assume f(x) = 0, i.e., ax = 0, so x = a 1 0 = 0, so x is not in S, contradiction. Note that a 1 exists because a 0(mod p)). Also note that if x y(mod p), then ax ay(mod p). (because if ax = ay(mod p), then we can multiply on both sides by a 1 and we obtain x = y(mod p), contradiction.) So a 1, a 2,..., a (p 1) are the same as 1, 2,..., (p 1), perhaps in a different order. Then (a 1) (a 2)... (a (p 1)) = (p 1)(mod p). So, a p 1 ( (p 1)) = ( (p 1))(mod p). Now we divide both sides by ( (p 1)) (why is it ok to divide?) and we obtain that a p 1 = 1(mod p). Example: 2 10 = 1(mod 11) 2 53 =?(mod 11) 2 53 = (2 10 ) = 1 8(mod 11) = 8(mod 11). Let s consider now that we work modulo n and n is not a prime number. φ(n) = number of integers between 1 and n that are relatively prime with n. Ex: n = 10, φ(10) = 4, because 1, 3, 7, 9 are all the numbers less than 10 that are relatively prime with

16 φ(n) is called the Euler s φ function. If p is prime, φ(p) = (p 1). φ(p r ) = p r p r 1 = (1 1) p pr. In general, for any integer n, φ(n) = n p n (1 1). p Theorem 9 (Euler s Theorem) If gcd(a, n) = 1, then a φ(n) = 1(mod n). Example: what are the last 3 digits of 7 803? We need (mod 1000). φ(1000) = 1000(1 1/2)(1 1/5) = 400. So = 1(mod 1000). Then = = = 343(mod 1000). So, we have the following principle, which will be used a lot. When we work mod n, we can reduce the exponent mod φ(n). So when we do modular arithmetic mod n, we can reduce in the base mod n and in the exponent mod φ(n). Primitive Roots (also called generators) Let us look at the powers of 3 modulo = 3, 3 2 = 2, 3 3 = 6, 3 4 = 4, 3 5 = 5, 3 6 = 1, after which, of course, they start to repeat. We have obtained {1, 2, 3, 4, 5, 6}, all the non-zero residues modulo 7. 3 is said to be a primitive root mod 7 (or a generator mod 7). Definition 10 If p is a prime number, a primitive root mod p is a number whose powers yield every nonzero residue mod p. 16

17 Properties: if g is a primitive root mod p, then g n = 1(mod p) iff n = 0(mod p 1). if g is a primitive root mod p, then g j = g k (mod p) iff j = k(mod p 1). there are φ(p 1) primitive roots mod p. Square roots mod n Problem: Solve the equation x 2 = b(mod n). We ll consider the cases: (1) n is a prime number, and (2) n = p q, with p and q primes. Case (1) is easy to solve. Regarding case (2): It is computationally equivalent to factoring in the following sense: (A) the equation can be solved fast if we know the factorization of n, and, (B) conversely, if we know the solutions, then we can factor fast the number n. Case 1. n = p, p prime. There are two possibilities: p = 1(mod 4) and p = 3(mod 4). The subcase p = 1(mod 4): there is an efficient algorithm that solves the equation. (I will not present the algorithm; can be found in the literature, ask me for references). The subcase p = 3(mod 4): It is even easier, because the solutions can be found with a simple formula. 17

18 Proposition 11 Let p = 3(mod 4) be a prime. let b be an integer, b 0(mod p). Then one and only one of b and b is a square and the square roots (of the one who is a square) are x = ±b (p+1)/4. The proof is not hard, but we ll skip it. Example: (a) Find the sqrt of 5(mod 11). 11 = , so 11 = 3(mod 4), so we can use the proposition. We compute 5 (11+1)/4 = 5 3 = 4(mod 11). Since 4 2 = 5(mod 11), 5 is a square and the sqrt are 4 and 4 = 7(mod 11). (b) Find the sqrt of 2(mod 11). We can use the proposition, for the same reason. We compute 2 (11+1)/4 = 2 3 = 8(mod 11). But 8 2 = 64 = 9 2(mod 11), so 8 is a sqrt of 2, and 2 is not a square (mod 11). Case 2: n = p q, with p and q primes. If we know p and q, then it s easy to solve the equation. The key is to use CRT (and actually we have seen the method when we discussed CRT). Example: x 2 = 71(mod 77). Note that 77 = We have: x 2 = 71 = 1(mod 7) and x 2 = 71 = 5(mod 11). Using case 1, we solve the two equations and we obtain: x = ±1(mod 7) and x = ±4(mod 11). Now we use the CRT, and we get 4 solutions: x = ±15, ±29(mod 77). 18

19 The conclusion is that if we can factor n and get p and q, then we can find the 4 solutions of the equation x 2 = b(mod n). Now we prove statement (B). Suppose we can find the 4 solutions of the equation x 2 = b(mod n), where b 0. We show that having this information allows us to factor n fast. Let the 4 solutions be ±a and ±c, with a ±c. So a 2 = c 2 (mod n). Then a 2 c 2 = 0( mod n), so (a+c)(a c) = 0( mod n), so (a+c)(a c) = k p q, for some integer k. Then p must divide (a+c) or (a c) (because p is prime). Let s say that p divides (a + c) (the other case is similar). It cannot be that q also divides (a + c), because otherwise (a + c) = 0(mod n), which is not true (because a c(mod n)). Therefore gcd(a + c, n) = p. Consequently we can use the Euclidean algorithm and find p (and after that q). Thus we have established the following: Let n = p q, with p and q primes, and let b 0(mod n). Then finding the four solutions of the equation x 2 = b(mod n) is computationally equivalent to factoring n. Computationally equivalent: if we can do one of them efficiently, we can do the other one efficiently as well. Formally we have shown that SQUARE-ROOT is polynomial-time reducible to FACTORING, and vice-versa, FACTORING is polynomial-time reducible to SQUARE- ROOT. 19

20 Since we believe that factoring n is very hard, the above implies that solving x 2 = b(mod n) is probably also very hard. 20

### Basic elements of number theory

Cryptography Basic elements of number theory Marius Zimand 1 Divisibility, prime numbers By default all the variables, such as a, b, k, etc., denote integer numbers. Divisibility a 0 divides b if b = a

### Number Theory and Group Theoryfor Public-Key Cryptography

Number Theory and Group Theory for Public-Key Cryptography TDA352, DIT250 Wissam Aoudi Chalmers University of Technology November 21, 2017 Wissam Aoudi Number Theory and Group Theoryfor Public-Key Cryptography

### 2.3 In modular arithmetic, all arithmetic operations are performed modulo some integer.

CHAPTER 2 INTRODUCTION TO NUMBER THEORY ANSWERS TO QUESTIONS 2.1 A nonzero b is a divisor of a if a = mb for some m, where a, b, and m are integers. That is, b is a divisor of a if there is no remainder

### 4 Number Theory and Cryptography

4 Number Theory and Cryptography 4.1 Divisibility and Modular Arithmetic This section introduces the basics of number theory number theory is the part of mathematics involving integers and their properties.

### LECTURE NOTES IN CRYPTOGRAPHY

1 LECTURE NOTES IN CRYPTOGRAPHY Thomas Johansson 2005/2006 c Thomas Johansson 2006 2 Chapter 1 Abstract algebra and Number theory Before we start the treatment of cryptography we need to review some basic

### Numbers. Çetin Kaya Koç Winter / 18

Çetin Kaya Koç http://koclab.cs.ucsb.edu Winter 2016 1 / 18 Number Systems and Sets We represent the set of integers as Z = {..., 3, 2, 1,0,1,2,3,...} We denote the set of positive integers modulo n as

### Applied Cryptography and Computer Security CSE 664 Spring 2017

Applied Cryptography and Computer Security Lecture 11: Introduction to Number Theory Department of Computer Science and Engineering University at Buffalo 1 Lecture Outline What we ve covered so far: symmetric

### Number Theory. Modular Arithmetic

Number Theory The branch of mathematics that is important in IT security especially in cryptography. Deals only in integer numbers and the process can be done in a very fast manner. Modular Arithmetic

### Number Theory. CSS322: Security and Cryptography. Sirindhorn International Institute of Technology Thammasat University CSS322. Number Theory.

CSS322: Security and Cryptography Sirindhorn International Institute of Technology Thammasat University Prepared by Steven Gordon on 29 December 2011 CSS322Y11S2L06, Steve/Courses/2011/S2/CSS322/Lectures/number.tex,

### 3 The fundamentals: Algorithms, the integers, and matrices

3 The fundamentals: Algorithms, the integers, and matrices 3.4 The integers and division This section introduces the basics of number theory number theory is the part of mathematics involving integers

### CPSC 467b: Cryptography and Computer Security

CPSC 467b: Cryptography and Computer Security Michael J. Fischer Lecture 8 February 1, 2012 CPSC 467b, Lecture 8 1/42 Number Theory Needed for RSA Z n : The integers mod n Modular arithmetic GCD Relatively

### Mathematics for Cryptography

Mathematics for Cryptography Douglas R. Stinson David R. Cheriton School of Computer Science University of Waterloo Waterloo, Ontario, N2L 3G1, Canada March 15, 2016 1 Groups and Modular Arithmetic 1.1

### Chapter 5. Modular arithmetic. 5.1 The modular ring

Chapter 5 Modular arithmetic 5.1 The modular ring Definition 5.1. Suppose n N and x, y Z. Then we say that x, y are equivalent modulo n, and we write x y mod n if n x y. It is evident that equivalence

### Applied Cryptography and Computer Security CSE 664 Spring 2018

Applied Cryptography and Computer Security Lecture 12: Introduction to Number Theory II Department of Computer Science and Engineering University at Buffalo 1 Lecture Outline This time we ll finish the

### Know the Well-ordering principle: Any set of positive integers which has at least one element contains a smallest element.

The first exam will be on Monday, June 8, 202. The syllabus will be sections. and.2 in Lax, and the number theory handout found on the class web site, plus the handout on the method of successive squaring

### Number Theory Proof Portfolio

Number Theory Proof Portfolio Jordan Rock May 12, 2015 This portfolio is a collection of Number Theory proofs and problems done by Jordan Rock in the Spring of 2014. The problems are organized first by

### CPSC 467: Cryptography and Computer Security

CPSC 467: Cryptography and Computer Security Michael J. Fischer Lecture 9 September 30, 2015 CPSC 467, Lecture 9 1/47 Fast Exponentiation Algorithms Number Theory Needed for RSA Elementary Number Theory

### Elementary Number Theory Review. Franz Luef

Elementary Number Theory Review Principle of Induction Principle of Induction Suppose we have a sequence of mathematical statements P(1), P(2),... such that (a) P(1) is true. (b) If P(k) is true, then

### 1 Overview and revision

MTH6128 Number Theory Notes 1 Spring 2018 1 Overview and revision In this section we will meet some of the concerns of Number Theory, and have a brief revision of some of the relevant material from Introduction

### Congruence Classes. Number Theory Essentials. Modular Arithmetic Systems

Cryptography Introduction to Number Theory 1 Preview Integers Prime Numbers Modular Arithmetic Totient Function Euler's Theorem Fermat's Little Theorem Euclid's Algorithm 2 Introduction to Number Theory

### Topics in Cryptography. Lecture 5: Basic Number Theory

Topics in Cryptography Lecture 5: Basic Number Theory Benny Pinkas page 1 1 Classical symmetric ciphers Alice and Bob share a private key k. System is secure as long as k is secret. Major problem: generating

### For your quiz in recitation this week, refer to these exercise generators:

Monday, Oct 29 Today we will talk about inverses in modular arithmetic, and the use of inverses to solve linear congruences. For your quiz in recitation this week, refer to these exercise generators: GCD

### Introduction to Cryptography CS 355 Lecture 3

Introduction to Cryptography CS 355 Lecture 3 Elementary Number Theory (1) CS 355 Fall 2005/Lecture 3 1 Review of Last Lecture Ciphertext-only attack: Known-plaintext attack: Chosen-plaintext: Chosen-ciphertext:

### NUMBER THEORY. Anwitaman DATTA SCSE, NTU Singapore CX4024. CRYPTOGRAPHY & NETWORK SECURITY 2018, Anwitaman DATTA

NUMBER THEORY Anwitaman DATTA SCSE, NTU Singapore Acknowledgement: The following lecture slides are based on, and uses material from the text book Cryptography and Network Security (various eds) by William

### Lecture 4: Number theory

Lecture 4: Number theory Rajat Mittal IIT Kanpur In the next few classes we will talk about the basics of number theory. Number theory studies the properties of natural numbers and is considered one of

### With Question/Answer Animations. Chapter 4

With Question/Answer Animations Chapter 4 Chapter Motivation Number theory is the part of mathematics devoted to the study of the integers and their properties. Key ideas in number theory include divisibility

### ICS141: Discrete Mathematics for Computer Science I

ICS141: Discrete Mathematics for Computer Science I Dept. Information & Computer Sci., Jan Stelovsky based on slides by Dr. Baek and Dr. Still Originals by Dr. M. P. Frank and Dr. J.L. Gross Provided by

### Lecture notes: Algorithms for integers, polynomials (Thorsten Theobald)

Lecture notes: Algorithms for integers, polynomials (Thorsten Theobald) 1 Euclid s Algorithm Euclid s Algorithm for computing the greatest common divisor belongs to the oldest known computing procedures

### Introduction to Public-Key Cryptosystems:

Introduction to Public-Key Cryptosystems: Technical Underpinnings: RSA and Primality Testing Modes of Encryption for RSA Digital Signatures for RSA 1 RSA Block Encryption / Decryption and Signing Each

### Chapter 3 Basic Number Theory

Chapter 3 Basic Number Theory What is Number Theory? Well... What is Number Theory? Well... Number Theory The study of the natural numbers (Z + ), especially the relationship between different sorts of

### Number Theory Notes Spring 2011

PRELIMINARIES The counting numbers or natural numbers are 1, 2, 3, 4, 5, 6.... The whole numbers are the counting numbers with zero 0, 1, 2, 3, 4, 5, 6.... The integers are the counting numbers and zero

### Introduction to Information Security

Introduction to Information Security Lecture 5: Number Theory 007. 6. Prof. Byoungcheon Lee sultan (at) joongbu. ac. kr Information and Communications University Contents 1. Number Theory Divisibility

### Chapter 4 Finite Fields

Chapter 4 Finite Fields Introduction will now introduce finite fields of increasing importance in cryptography AES, Elliptic Curve, IDEA, Public Key concern operations on numbers what constitutes a number

### Some Facts from Number Theory

Computer Science 52 Some Facts from Number Theory Fall Semester, 2014 These notes are adapted from a document that was prepared for a different course several years ago. They may be helpful as a summary

### COMP239: Mathematics for Computer Science II. Prof. Chadi Assi EV7.635

COMP239: Mathematics for Computer Science II Prof. Chadi Assi assi@ciise.concordia.ca EV7.635 The Euclidean Algorithm The Euclidean Algorithm Finding the GCD of two numbers using prime factorization is

### CHAPTER 6. Prime Numbers. Definition and Fundamental Results

CHAPTER 6 Prime Numbers Part VI of PJE. Definition and Fundamental Results 6.1. Definition. (PJE definition 23.1.1) An integer p is prime if p > 1 and the only positive divisors of p are 1 and p. If n

### CIS 551 / TCOM 401 Computer and Network Security

CIS 551 / TCOM 401 Computer and Network Security Spring 2008 Lecture 15 3/20/08 CIS/TCOM 551 1 Announcements Project 3 available on the web. Get the handout in class today. Project 3 is due April 4th It

### CS March 17, 2009

Discrete Mathematics CS 2610 March 17, 2009 Number Theory Elementary number theory, concerned with numbers, usually integers and their properties or rational numbers mainly divisibility among integers

### An integer p is prime if p > 1 and p has exactly two positive divisors, 1 and p.

Chapter 6 Prime Numbers Part VI of PJE. Definition and Fundamental Results Definition. (PJE definition 23.1.1) An integer p is prime if p > 1 and p has exactly two positive divisors, 1 and p. If n > 1

### Number Theory and Algebra: A Brief Introduction

Number Theory and Algebra: A Brief Introduction Indian Statistical Institute Kolkata May 15, 2017 Elementary Number Theory: Modular Arithmetic Definition Let n be a positive integer and a and b two integers.

### Course 2BA1: Trinity 2006 Section 9: Introduction to Number Theory and Cryptography

Course 2BA1: Trinity 2006 Section 9: Introduction to Number Theory and Cryptography David R. Wilkins Copyright c David R. Wilkins 2006 Contents 9 Introduction to Number Theory and Cryptography 1 9.1 Subgroups

### CSC 474 Information Systems Security

CSC Information Systems Security Topic. Basic Number Theory CSC Dr. Peng Ning Basic Number Theory We are talking about integers! Divisor We say that b divides a if a = mb for some m, denoted b a. b is

### MATH 145 Algebra, Solutions to Assignment 4

MATH 145 Algebra, Solutions to Assignment 4 1: a) Find the inverse of 178 in Z 365. Solution: We find s and t so that 178s + 365t = 1, and then 178 1 = s. The Euclidean Algorithm gives 365 = 178 + 9 178

### Outline. Number Theory and Modular Arithmetic. p-1. Definition: Modular equivalence a b [mod n] (a mod n) = (b mod n) n (a-b)

Great Theoretical Ideas In CS Victor Adamchik CS - Lecture Carnegie Mellon University Outline Number Theory and Modular Arithmetic p- p Working modulo integer n Definitions of Z n, Z n Fundamental lemmas

### Chapter 9 Mathematics of Cryptography Part III: Primes and Related Congruence Equations

Chapter 9 Mathematics of Cryptography Part III: Primes and Related Congruence Equations Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 9.1 Chapter 9 Objectives

### CHAPTER 3. Congruences. Congruence: definitions and properties

CHAPTER 3 Congruences Part V of PJE Congruence: definitions and properties Definition. (PJE definition 19.1.1) Let m > 0 be an integer. Integers a and b are congruent modulo m if m divides a b. We write

### Lemma 1.2. (1) If p is prime, then ϕ(p) = p 1. (2) If p q are two primes, then ϕ(pq) = (p 1)(q 1).

1 Background 1.1 The group of units MAT 3343, APPLIED ALGEBRA, FALL 2003 Handout 3: The RSA Cryptosystem Peter Selinger Let (R, +, ) be a ring. Then R forms an abelian group under addition. R does not

### Beautiful Mathematics

Beautiful Mathematics 1. Principle of Mathematical Induction The set of natural numbers is the set of positive integers {1, 2, 3,... } and is denoted by N. The Principle of Mathematical Induction is a

### a the relation arb is defined if and only if = 2 k, k

DISCRETE MATHEMATICS Past Paper Questions in Number Theory 1. Prove that 3k + 2 and 5k + 3, k are relatively prime. (Total 6 marks) 2. (a) Given that the integers m and n are such that 3 (m 2 + n 2 ),

### Course MA2C02, Hilary Term 2013 Section 9: Introduction to Number Theory and Cryptography

Course MA2C02, Hilary Term 2013 Section 9: Introduction to Number Theory and Cryptography David R. Wilkins Copyright c David R. Wilkins 2000 2013 Contents 9 Introduction to Number Theory 63 9.1 Subgroups

### Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry. Spring 2006

Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry Spring 2006 1 / 1 Computer Science & Engineering 235 Introduction to Discrete Mathematics Sections 2.4 2.6 of Rosen Introduction I When talking

### 1. Factorization Divisibility in Z.

8 J. E. CREMONA 1.1. Divisibility in Z. 1. Factorization Definition 1.1.1. Let a, b Z. Then we say that a divides b and write a b if b = ac for some c Z: a b c Z : b = ac. Alternatively, we may say that

### ECE596C: Handout #11

ECE596C: Handout #11 Public Key Cryptosystems Electrical and Computer Engineering, University of Arizona, Loukas Lazos Abstract In this lecture we introduce necessary mathematical background for studying

### This is a recursive algorithm. The procedure is guaranteed to terminate, since the second argument decreases each time.

8 Modular Arithmetic We introduce an operator mod. Let d be a positive integer. For c a nonnegative integer, the value c mod d is the remainder when c is divided by d. For example, c mod d = 0 if and only

### Number Theory A focused introduction

Number Theory A focused introduction This is an explanation of RSA public key cryptography. We will start from first principles, but only the results that are needed to understand RSA are given. We begin

### The set of integers will be denoted by Z = {, -3, -2, -1, 0, 1, 2, 3, 4, }

Integers and Division 1 The Integers and Division This area of discrete mathematics belongs to the area of Number Theory. Some applications of the concepts in this section include generating pseudorandom

### Notes. Number Theory: Applications. Notes. Number Theory: Applications. Notes. Hash Functions I

Number Theory: Applications Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry Fall 2007 Computer Science & Engineering 235 Introduction to Discrete Mathematics Sections 3.4 3.7 of Rosen cse235@cse.unl.edu

### 4 Powers of an Element; Cyclic Groups

4 Powers of an Element; Cyclic Groups Notation When considering an abstract group (G, ), we will often simplify notation as follows x y will be expressed as xy (x y) z will be expressed as xyz x (y z)

### Number theory (Chapter 4)

EECS 203 Spring 2016 Lecture 10 Page 1 of 8 Number theory (Chapter 4) Review Questions: 1. Does 5 1? Does 1 5? 2. Does (129+63) mod 10 = (129 mod 10)+(63 mod 10)? 3. Does (129+63) mod 10 = ((129 mod 10)+(63

### MTH 346: The Chinese Remainder Theorem

MTH 346: The Chinese Remainder Theorem March 3, 2014 1 Introduction In this lab we are studying the Chinese Remainder Theorem. We are going to study how to solve two congruences, find what conditions are

### Mathematical Foundations of Public-Key Cryptography

Mathematical Foundations of Public-Key Cryptography Adam C. Champion and Dong Xuan CSE 4471: Information Security Material based on (Stallings, 2006) and (Paar and Pelzl, 2010) Outline Review: Basic Mathematical

### ECEN 5022 Cryptography

Elementary Algebra and Number Theory University of Colorado Spring 2008 Divisibility, Primes Definition. N denotes the set {1, 2, 3,...} of natural numbers and Z denotes the set of integers {..., 2, 1,

### CPSC 467: Cryptography and Computer Security

CPSC 467: Cryptography and Computer Security Michael J. Fischer Lecture 14 October 23, 2017 CPSC 467, Lecture 14 1/42 Computing in Z n Modular multiplication Modular inverses Extended Euclidean algorithm

### ALGEBRA. 1. Some elementary number theory 1.1. Primes and divisibility. We denote the collection of integers

ALGEBRA CHRISTIAN REMLING 1. Some elementary number theory 1.1. Primes and divisibility. We denote the collection of integers by Z = {..., 2, 1, 0, 1,...}. Given a, b Z, we write a b if b = ac for some

### Elementary Number Theory MARUCO. Summer, 2018

Elementary Number Theory MARUCO Summer, 2018 Problem Set #0 axiom, theorem, proof, Z, N. Axioms Make a list of axioms for the integers. Does your list adequately describe them? Can you make this list as

### 8 Primes and Modular Arithmetic

8 Primes and Modular Arithmetic 8.1 Primes and Factors Over two millennia ago already, people all over the world were considering the properties of numbers. One of the simplest concepts is prime numbers.

### SOLUTIONS Math 345 Homework 6 10/11/2017. Exercise 23. (a) Solve the following congruences: (i) x (mod 12) Answer. We have

Exercise 23. (a) Solve the following congruences: (i) x 101 7 (mod 12) Answer. We have φ(12) = #{1, 5, 7, 11}. Since gcd(7, 12) = 1, we must have gcd(x, 12) = 1. So 1 12 x φ(12) = x 4. Therefore 7 12 x

### Discrete Mathematics GCD, LCM, RSA Algorithm

Discrete Mathematics GCD, LCM, RSA Algorithm Abdul Hameed http://informationtechnology.pk/pucit abdul.hameed@pucit.edu.pk Lecture 16 Greatest Common Divisor 2 Greatest common divisor The greatest common

### Ch 4.2 Divisibility Properties

Ch 4.2 Divisibility Properties - Prime numbers and composite numbers - Procedure for determining whether or not a positive integer is a prime - GCF: procedure for finding gcf (Euclidean Algorithm) - Definition:

### Finite Fields. Mike Reiter

1 Finite Fields Mike Reiter reiter@cs.unc.edu Based on Chapter 4 of: W. Stallings. Cryptography and Network Security, Principles and Practices. 3 rd Edition, 2003. Groups 2 A group G, is a set G of elements

### NUMBER THEORY AND CODES. Álvaro Pelayo WUSTL

NUMBER THEORY AND CODES Álvaro Pelayo WUSTL Talk Goal To develop codes of the sort can tell the world how to put messages in code (public key cryptography) only you can decode them Structure of Talk Part

### Public Key Encryption

Public Key Encryption 3/13/2012 Cryptography 1 Facts About Numbers Prime number p: p is an integer p 2 The only divisors of p are 1 and p s 2, 7, 19 are primes -3, 0, 1, 6 are not primes Prime decomposition

### Introduction to Cryptography. Lecture 6

Introduction to Cryptography Lecture 6 Benny Pinkas page 1 Public Key Encryption page 2 Classical symmetric ciphers Alice and Bob share a private key k. System is secure as long as k is secret. Major problem:

### Theory of RSA. Hiroshi Toyoizumi 1. December 8,

Theory of RSA Hiroshi Toyoizumi 1 December 8, 2005 1 E-mail: toyoizumi@waseda.jp 2 Introduction This is brief introduction of number theory related to the so-called RSA cryptography. This handout is based

### Addition. Ch1 - Algorithms with numbers. Multiplication. al-khwārizmī. al-khwārizmī. Division 53+35=88. Cost? (n number of bits) 13x11=143. Cost?

Ch - Algorithms with numbers Addition Basic arithmetic Addition ultiplication Division odular arithmetic factoring is hard Primality testing 53+35=88 Cost? (n number of bits) O(n) ultiplication al-khwārizmī

### Lecture 3.1: Public Key Cryptography I

Lecture 3.1: Public Key Cryptography I CS 436/636/736 Spring 2015 Nitesh Saxena Today s Informative/Fun Bit Acoustic Emanations http://www.google.com/search?source=ig&hl=en&rlz=&q=keyboard+acoustic+em

### [Part 2] Asymmetric-Key Encipherment. Chapter 9. Mathematics of Cryptography. Objectives. Contents. Objectives

[Part 2] Asymmetric-Key Encipherment Mathematics of Cryptography Forouzan, B.A. Cryptography and Network Security (International Edition). United States: McGraw Hill, 2008. Objectives To introduce prime

### NOTES ON SIMPLE NUMBER THEORY

NOTES ON SIMPLE NUMBER THEORY DAMIEN PITMAN 1. Definitions & Theorems Definition: We say d divides m iff d is positive integer and m is an integer and there is an integer q such that m = dq. In this case,

### CSC 474 Network Security. Outline. GCD and Euclid s Algorithm. GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation Discrete Logarithms

Computer Science CSC 474 Network Security Topic 5.1 Basic Number Theory -- Foundation of Public Key Cryptography CSC 474 Dr. Peng Ning 1 Outline GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation

### CS483 Design and Analysis of Algorithms

CS483 Design and Analysis of Algorithms Lectures 2-3 Algorithms with Numbers Instructor: Fei Li lifei@cs.gmu.edu with subject: CS483 Office hours: STII, Room 443, Friday 4:00pm - 6:00pm or by appointments

### Chapter 1. Greatest common divisor. 1.1 The division theorem. In the beginning, there are the natural numbers 0, 1, 2, 3, 4,...,

Chapter 1 Greatest common divisor 1.1 The division theorem In the beginning, there are the natural numbers 0, 1, 2, 3, 4,..., which constitute the set N. Addition and multiplication are binary operations

### Chapter 8. Introduction to Number Theory

Chapter 8 Introduction to Number Theory CRYPTOGRAPHY AND NETWORK SECURITY 1 Index 1. Prime Numbers 2. Fermat`s and Euler`s Theorems 3. Testing for Primality 4. Discrete Logarithms 2 Prime Numbers 3 Prime

### Public-key Cryptography: Theory and Practice

Public-key Cryptography Theory and Practice Department of Computer Science and Engineering Indian Institute of Technology Kharagpur Chapter 2: Mathematical Concepts Divisibility Congruence Quadratic Residues

### Outline. Some Review: Divisors. Common Divisors. Primes and Factors. b divides a (or b is a divisor of a) if a = mb for some m

Outline GCD and Euclid s Algorithm AIT 682: Network and Systems Security Topic 5.1 Basic Number Theory -- Foundation of Public Key Cryptography Modulo Arithmetic Modular Exponentiation Discrete Logarithms

### Outline. AIT 682: Network and Systems Security. GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation Discrete Logarithms

AIT 682: Network and Systems Security Topic 5.1 Basic Number Theory -- Foundation of Public Key Cryptography Instructor: Dr. Kun Sun Outline GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation

### A Guide to Arithmetic

A Guide to Arithmetic Robin Chapman August 5, 1994 These notes give a very brief resumé of my number theory course. Proofs and examples are omitted. Any suggestions for improvements will be gratefully

### Remainders. We learned how to multiply and divide in elementary

Remainders We learned how to multiply and divide in elementary school. As adults we perform division mostly by pressing the key on a calculator. This key supplies the quotient. In numerical analysis and

### Intermediate Math Circles February 29, 2012 Linear Diophantine Equations I

Intermediate Math Circles February 29, 2012 Linear Diophantine Equations I Diophantine equations are equations intended to be solved in the integers. We re going to focus on Linear Diophantine Equations.

### Part IA Numbers and Sets

Part IA Numbers and Sets Definitions Based on lectures by A. G. Thomason Notes taken by Dexter Chua Michaelmas 2014 These notes are not endorsed by the lecturers, and I have modified them (often significantly)

### The number of ways to choose r elements (without replacement) from an n-element set is. = r r!(n r)!.

The first exam will be on Friday, September 23, 2011. The syllabus will be sections 0.1 through 0.4 and 0.6 in Nagpaul and Jain, and the corresponding parts of the number theory handout found on the class

### Modular Arithmetic Instructor: Marizza Bailey Name:

Modular Arithmetic Instructor: Marizza Bailey Name: 1. Introduction to Modular Arithmetic If someone asks you what day it is 145 days from now, what would you answer? Would you count 145 days, or find

### Carmen s Core Concepts (Math 135)

Carmen s Core Concepts (Math 135) Carmen Bruni University of Waterloo Week 8 1 The following are equivalent (TFAE) 2 Inverses 3 More on Multiplicative Inverses 4 Linear Congruence Theorem 2 [LCT2] 5 Fermat

### NUMBER SYSTEMS. Number theory is the study of the integers. We denote the set of integers by Z:

NUMBER SYSTEMS Number theory is the study of the integers. We denote the set of integers by Z: Z = {..., 3, 2, 1, 0, 1, 2, 3,... }. The integers have two operations defined on them, addition and multiplication,

### Discrete Mathematics with Applications MATH236

Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science University of KwaZulu-Natal Pietermaritzburg Campus Semester 1, 2013 Tong-Viet

### Senior Math Circles Cryptography and Number Theory Week 2

Senior Math Circles Cryptography and Number Theory Week 2 Dale Brydon Feb. 9, 2014 1 Divisibility and Inverses At the end of last time, we saw that not all numbers have inverses mod n, but some do. We

### Homework #2 solutions Due: June 15, 2012

All of the following exercises are based on the material in the handout on integers found on the class website. 1. Find d = gcd(475, 385) and express it as a linear combination of 475 and 385. That is

### Algebra for error control codes

Algebra for error control codes EE 387, Notes 5, Handout #7 EE 387 concentrates on block codes that are linear: Codewords components are linear combinations of message symbols. g 11 g 12 g 1n g 21 g 22