Discrete mathematics I - Number theory

Size: px
Start display at page:

Download "Discrete mathematics I - Number theory"

Transcription

1 Discrete mathematics I - Number theory Emil Vatai <vatai@inf.elte.hu> (based on hungarian slides by László Mérai) 1 January 31, Financed from the financial support ELTE won from the Higher Education Restructuring Fund of the Hungarian Government.

2 Number theory Divisibility Divisibility If a and b are rational numbers, the division a/b can always be performed (and the result is a rational number). If a and b are integers, the division a/b can not always be performed (the quotient will not always be an integer). Definition (Divisibility) The integer a is a divisor of the integer b: a b, if there exists an integer c for which a c = b (that is b/a is an integer if a 0). Example (Divisibility) 1 13, because 1 13 = 13; 1 n, because 1 n = n; 6 12, because 6 2 = 12; 6 12, because ( 6) ( 2) = 12. The definition can be extended to Gaussian-integers: {a + bi : a, b Z}. i 13, because i ( 13i) = i 2, because (1 + i) (1 i) = 2.

3 Number theory Divisibility Properties of divisibility Properies For each a, b, c, Z 1. a a; 2. a b b c a c; 3. a b b a a = ±b; 4. a b a b aa bb ; 5. a b ac bc; 6. ac bc c 0 a b; 7. a b 1,..., a b k a c 1 b c k b k 8. a 0, since a 0 = 0; 9. 0 a a = 0; Example (Divisibility) ; ; = ±3; ; ; ; , c 1 +9c 2 for each c 1, c a 0, since a 0 = 0; 9. 0 a 0 c = a;

4 Number theory Divisibility Units The factor ±1 is irrelevant for divisibility. Definition (Unit) If an ε is a divisor of every other number, then ε is called a unit. Proposition There are two units in the set of integers: 1, 1. Proof. ±1 are clearly units. Conversely, if ε is a unit, then 1 = ε q for some integer q. Because ε 1, q 1 ε = 1, that is ε = ±1. Example (Unit) In the set of Gaussian-integers i is a unit: a + bi = i(b ai).

5 Number theory Divisibility Associated elements The integers 12 and 12 are the same from the perspective of divisibility. Definition (Associated elements) Two numbers are associated if they are each others divisors. Remark a and b are associated if and only if a b and b a. Definition (Trivial divisor) Trivial divisors of n are the numbers associated with n and the units. Other divisors are proper divisors. Example (Divisor of 6) The divisors: {±1, ±2, ±3, ±6} Trivial divisors are: {±1, ±6}

6 Number theory Primes, irreducible elements Primes, irreducible elements Definition (Irreducible) A nonzero and non-unit number is irreducible if it has only trivial divisors. Example (Irreducible elements) Integers 2, 2, 3, 3, 5, 5 are irreducible; 6 is not irreducible, because 6 = 2 3. Definition (Prime) A non-zero, non-unit p number is a prime number, if p ab (p a p b) (for any a, b). Example (Primes) 2, 2, 3, 3, 5, 5 are prime; 6 is not a prime number, because but 6 2 and 6 3.

7 Number theory Primes, irreducible elements Primes, irreducibles Theorem (Primes and irreducbles) Each prime number is irreducible. Proof. Let p be a prime number and let p = ab be a factorization. We have to prove, that a or b is a unit. Because p = ab, p ab, which means e.g. p a. Then a = pk = a(bk), i.e. bk = 1, implying that b and k are units. Remark The converse is not always true: In the set Z it is true, (see later); The set {a + bi 5 : a, b Z} it is not true.

8 Number theory Euclidean division Euclidean division Theorem (Euclidean division) For all integers a, b 0 there exist unique integers q and r for which a = bq + r 0 r < b. (1) Proof. This proof for non-negative numbers can be applied to all integers. 1. Existence: induction by a. If a < b, then a = b 0 + a (q = 0, r = a). If a b, then suppose that numbers less than a can be written as (1). Let a b = bq + r. Then a = b(q + 1) + r and let q = q + 1, r = r. 2. Uniqueness: Let a = bq + r = bq + r. Then b(q q ) = r r. This can be only if q = q and r = r.

9 Number theory Euclidean division Euclidean division Definition (mod) Let a and b be integers (b 0). Let a = b q + r (0 r < b ). Then a mod b = r. Remark: q = a/b, if b > 0, and q = a/b, if b < 0. Example (mod) 123 mod 10 = 3, 123 mod 100 = 23, 123 mod 1000 = 123; 123 mod 10 = 3, mod 10 = 7, 123 mod 100 = 77, 123 mod 1000 = 877; 123 mod 10 = 7,...

10 Number theory Euclidean division Euclidean division Example (mod) If it is 9 o clock now, what time will it be after 123 hours? Let us divide 123 by 24: 123 = = 12: noon! If it is 9 o clock now, what time will it be after 116 hours? Let us divide 116 by 24: 116 = So = 29. We have a reduction again: 29 = : it will be 5 A.M.! Which day of the week will the 10th of November be next year? Which day of the week was the 14th of September before two years? Mon= 0, Tue= 1, Wed= 2, Thu= 3, Fri= 4, Sat= 5, Sun= 6 Divide 365 by 7: 365 = Monday + 1 day = = 1 = Tuesday Divide ( ) (2012 was a leap year) by 7: 731 = 7 ( 105) + 4.

11 Number theory Euclidean division Numeral systems In the base 10 numeral system the number 123: 123 = = In the base 2 numeral system the number 123: (2) = = (10) Theorem (Representation of numbers) Let q > 1 be a fixed integer. Then each non-negative integer n can uniquely be written in the form n = k i=0 a i q i, where 0 a i < q is an integer, a k This expression is the number n written in the base q num. sys. 2. q is the base of the numeral system. 3. a 0,..., a k are the digits of n.

12 Number theory Euclidean division Numeral systems n written in the base q numeral system: n = k i=0 a i q i. Proof. The proof is by induction. 1. For n = 0 the theorem is true. 2. Suppose each integer less than n can be written uniquely in a base q numeral system. Because of the Euclidean division theorem, there exists a unique integer 0 a 0 < q, for which n = cq + a 0, that is, q n a 0. Because of the induction hypothesis we can express n a 0 q = k i=1 a i q i 1 (in a base q numeral system), and this expression is unique. Then n = k i=0 a i q i.

13 Number theory Euclidean division Numeral systems The previous proof provides a method to express the numbers: Example (Representation) Let us write in base 2 numeral system the number n = 123 (expressed in base 10). n a i i n n mod 2 2 Digits

14 Number theory Euclidean algorithm Greatest common divisor Definition (Greatest common divisor) The integer d is the greatest common divisor (or gcd) of integers a and b if: d a, d b, and if c a, c b then c d. The integer d is the gcd of integers a 1, a 2,..., a n (n N + ) if: d a 1, d a 2,... d a n, and if c a 1, c a 2,... c a n then c d. Least common multiple The least common multiple (or lcm) of numbers a and b is m if: a m, b m, and a c, b c m c. The lcm of numbers a 1, a 2,..., a n (n N + ) is m if: a 1 m, a 2 m,..., a n m and if a 1 c, a 2 c,..., a n c then m c. Notation Let (a, b) = gcd(a, b) be the non-negative greatest common divisor! Let [a, b] = lcm(a, b) be the non-negative least common multiple!

15 Number theory Euclidean algorithm Greatest common divisor Definition (Relative prime) The numbers a and b are relative prime if (a, b) = 1. The numbers a 1, a 2,..., a n are relative prime if (a 1, a 2,..., a n ) = 1 (i.e. if their greatest common divisor is one). The numbers a 1, a 2,..., a n are mutually (or pairwise) relative prime, if i j implies (a i, a j ) = 1. Remarks Attention! The greatest does not refer to the usual ordering: 3 is also the greatest common divisor of 12 and 9. The greatest common divisor is unique disregarding association.

16 Number theory Euclidean algorithm Euclidean algorithm Theorem (Euclidean algorithm) Each pair of integers has a greatest common divisor and it can be determined using the euclidean algorithm. Proof. If one of the numbers is 0, then the other one will be the gcd. Let a and b be non-zero integers. Let us do the following divisions: a = bq 1 + r 1, 0 < r 1 < b, b = r 1 q 2 + r 2, 0 < r 2 < r 1, r 1 = r 2 q 3 + r 3, 0 < r 3 < r 2,. r n 2 = r n 1 q n + r n, 0 < r n < r n 1, r n 1 = r n q n+1

17 Number theory Euclidean algorithm Proof (continued).

18 Number theory Euclidean algorithm a = bq 1 + r 1, 0 < r 1 < b, b = r 1 q 2 + r 2, 0 < r 2 < r 1, r 1 = r 2 q 3 + r 3, 0 < r 3 < r 2,. r n 2 = r n 1 q n + r n, 0 < r n < r n 1, r n 1 = r n q n+1 The algorithm terminates after a finite number of steps: b > r 1 > r 2 >.... The remainder r n is a common divisor: r n r n 1 r n r n 1 q n + r n = r n 2... r n b r n a. r n is the greatest common divisor: let c a, c b c a bq 1 = r 1 c b r 1 q 2 = r 2... c r n 2 r n 1 q n = r n.

19 Number theory Euclidean algorithm Calculating the GCD, euclidean algorithm Example (Euclidean algorithm) Let us calculate the value of (172, 62). i r i q i r i 2 = r i 1 q i + r i = = = = = The greatest common divisor: (172, 62) = 2

20 Number theory Euclidean algorithm Calculating the GCD using recursion Theorem (Theorem) Let a 0. If b = 0, then (a, b) = a. If b 0, then (a, b) = ( b, a mod b ). Proof. If b = 0, the theorem is trivial. Since (a, b) = ( a, b ), we can suppose that a, b > 0. If b 0, let us divide a by b : a = b q + (a mod b ). This is the first line of the euclidean alg. Example ((172,62)) (a, b) a mod b (172, 62) 48 (62, 48) 14 (48, 14) 6

21 Number theory Euclidean algorithm GCD, further observations Similarly, we can define the greatest common divisor of multiple numbers (HW): (a 1, a 2,..., a n ). Proposition (HW) Each collection a 1, a 2,..., a n of integers, has (there exists) a greatest common divisor (a 1, a 2,..., a n ) and (a 1, a 2,..., a n ) = ((... (a 1, a 2 ),... a n 1 ), a n ). Proposition (HW) For each a, b, c integer (ca, cb) = c(a, b) is true.

22 Number theory Euclidean algorithm Extended euclidean algorithm Theorem (Extended euclidean algorithm) For each a, b integer there exist integers x, y, so that (a, b) = x a + y b. Proof. Let q i, r i be the quotient and the remainder obtained by the euclidean algorithm. Let x 1 = 1, x 0 = 0 and for i 1 let x i = x i 2 q i x i 1. Similarly let y 1 = 0, y 0 = 1 and for i 1 let y i = y i 2 q i y i 1. Then for i 1, x i a + y i b = r i. Suppose for all j < i, x j a + y j b = r j is true. r i = r i 2 r i 1 q i, so r i = x i 2 a + y i 2 b (x i 1 a + y i 1 b)q i after rearranging, r i = x i a + y i b. Ergo x n a + y n b = r n = (a, b).

23 Number theory Euclidean algorithm Extended euclidean algorithm Algorithm: r i 2 = r i 1, q i + r i, x 1 = 1, x 0 = 0, x i = x i 2 q i x i 1 y 1 = 0, y 0 = 1, y i = y i 2 q i y i 1 Extended euclidean algorithm Let us calculate (172, 62) and solve the 172x + 62y = (172, 62) equation! i r n q n x i y i r i = 172x i + 62y i = = = ( 2) = 172 ( 1) = ( 11) = 172 ( 9)

24 Number theory Elementary number theory Irreducibles, primes (reminder) t is irreducible: if it has only trivial divisors of the form ε, t, ε t (where ε is a unit). p is prime: if p ab p a or p b. p is prime p is irreducible. On the set of integers the converse is also true. Theorem (Irreducible integers are prime) Every irreducible number is also a prime number. Proof. Let p be an irreducible number, and let p ab. Assume p b. Then p and b are relative prime. Using the extended euclidean algorithm we can obtain x, y integers, so that px + by = 1. Therefore pax + aby = a. Since p divides the left hand side, it also divides the right hand side: p a.

25 Number theory Elementary number theory The fundamental theorem of number theory Theorem (Fundamental theorem of number theory) Every non-zero, non-unit number can uniquely be written as a product of primes ignoring associated elements and order. Proof. The proof is only for non negative integers, but it can be generalized. Existence: Induction: for n = 2, n = 3 it is true (primes). Generally if n is prime, then we are finished, if not, it can be divided into a product in a non-trivial way. The factors are can be factorized base on the induction hypothesis. Uniqueness: Induction: for n = 2, n = 3 it is true (primes). Assume n = p 1 p 2 p k = q 1 q 2 q l, where p 1, p 2, p k, q 1, q 2,..., q l are primes. p 1 divides the left hand side it divides the right hand side, suppose p 1 = q 1. After

26 Number theory Elementary number theory Fundamental theorem of number theory Definition (Canonical form) The canonical form of a non-zero integer n is: n = ±p α 1 1 pα 2 2 pα l l = ± where p 1, p 2,..., p l are positive primes, α 1, α 2,..., α l positive integers. Corollary (HW) Let n, m > 1 positive integers: n = p α 1 1 pα 2 2 pα l m = p β 1 1 pβ 2 2 pβ l l, (where α i, β i 0 non-negative integers!). Then l i=1 p α i i (a, b) = p min{α 1,β 1 } 1 p min{α 2,β 2 } 2 p min{α l,β l } l, max{α 1,β 1 } max{α 2,β 2 } max{α l,β l } l,

27 Number theory Elementary number theory Number of divisors Definition (The τ function) τ(n) is the number of (positive) divisors for an integer n > 1. Calculating τ(n) Let n > 1 be an integer, n = p α 1 1 pα 2 2 pα l l its canonical form. Then τ(n) = (α 1 + 1) (α 2 + 1) (α l + 1). Proof. The possible divisors of n can be obtained by iterating all the β i exponents in the expression d = p β 1 1 pβ 2 2 pβ l l over the set {0, 1,..., α i }. There are α i + 1 choices for each exponent. Example (τ(n)) τ(6) = 4: divisors: 1, 2, 3, 6;τ(96) = 12: divisors: 1, 2, 3, 4, 6,... τ(2 3) = (1 + 1) (1 + 1); τ(2 5 3) = (5 + 1) (1 + 1).

28 Number theory Elementary number theory About primes Theorem (Euclid s theorem) There are infinitely many primes. Proof. Indirect. Assume there are finite many primes. Let them be p 1,..., p k. Consider the integer n = p 1 p k + 1. This is not divisible by either prime p 1,..., p k, so the factorization of n has to contain an additional prime. Theorem (Dirichlet s theorem) If a, d are integers, d > 0, (a, d) = 1, then there are infinitely many primes of the form ak + d.

29 Number theory Elementary number theory About primes Theorem (Prime number theorem) The number of primes x is x ln x x Number of primes x/ ln x , , , , 73 Sieve of Eratosthenes How to find all the primes up to the integer n. Start with all the integers from 2 to n. 2 is prime. The (non-trivial) multiples of 2 are not prime, so they are eliminated. The next number is 3 which is also a prime. The (non-trivial) multiples of 3 are not prime, so

30 For questions about divisibility, often only the remainder from the euclidean division is important: days of the week; number of hours,... Example (Equal remainders) 16 mod 3 = 1, 4 mod 3 = 1: for division by 3 we have 16 = 4. Definition (Congruence) Let a, b, m be integers. If m a b, then we say a is congruent to b with modulus m (or a and b are congruent modulo m) written as a b (mod m). If a and b are not congruent (with some modulus m) then they are incongruent.

31 Equivalent formulation Alternative notation The following all mean m a b a b (mod m), a b mod m, a b (m). Equivalent formulation: a b (mod m) a mod m = b mod m, that is we get the same remainder when dividing by m. Example () 16 4 (mod 3) since mod 3 = 1 = 4 mod 3; 16 4 (mod 2) since mod 2 = 0 = 4 mod 2; 16 4 (mod 5) since mod 5 = 1 4 = 4 mod 5.

32 Properties of congruence Theorem (Properties of congruence) 1. a a (mod m) (reflexivity); 2. a b (mod m) b a (mod m) (symmetry); 3. a b (mod m) b c (mod m) a c (mod m) (transitivity); Ergo, the congruence modulo m is an equivalence relation. Proof. 1. m 0 = a a; 2. m a b m b a = (a b); 3. m a b m b c m a c = (a b) + (b c);

33 Properties of congruence Theorem (Properties of congruence) 1. a b (mod m) m m a b (mod m ); 2. a b (mod m) c d (mod m) a + c b + d (mod m); 3. a b (mod m) c d (mod m) ac bd (mod m). Proof. 1. m m a b m a b; 2. m a b m c d m (a+c) (b+d) = (a b)+(c d); 3. a = q 1 m + b c = q 2 m + d ac = (q 1 m + b)(q 2 m + d) = m(q 1 q 2 m + q 1 d + q 2 b) + bd.

34 Properties of congruence Example (Properties of congruences) What is 345 mod 7 =? 345 = = = 9 2 (mod 7). Reminder: a b (mod m), c d (mod m) ac bd (mod m) Corollary If a b (mod m) then ac bc (mod m). Example (Properties of congruence) 14 6 (mod 8) then (mod 8) The converse is not true! (mod 8) but 7 3 (mod 8).

35 Divisibility and relative primes Theorem (Statement) a, b, c Z : (a bc (a, b) = 1 = a c) Proof. Using the extended Euclidean algorithm to obtain x and y, such that ax + by = 1, so c = xac + ybc = (xc)a + y(bc). Using the statement about the divisibility of linear combinations we have a c.

36 The converse is not true Theorem (Division) Let a, b, c, m be integers. Then ac bc (mod m) a b (mod m (c,m) ) Corollary ac bc (mod m), (c, m) = 1 a b (mod m). Example (Division) (mod 8) 7 3 (mod 8 2 ). Proof. Let d = (c, m). Then m c(a b) m d c ( m d (a b). Since d, c d we have m d (a b) a b (mod m d ). ) = 1,

37 Linear congruences Linear congruences Let us solve the congruence 2x 5 (mod 7). If x is a solution of x y (mod 7), then y is also a solution. Let us find the solution in the set {0, 1,..., 6}. x = 0 2x = 0 5 (mod 7); x = 1 2x = 2 5 (mod 7); x = 2 2x = 4 5 (mod 7); x = 3 2x = 6 5 (mod 7); x = 4 2x = (mod 7); x = 5 2x = (mod 7); x = 6 2x = 12 5 (mod 7). The solution of the congruence: {6 + 7k : k Z}. Is there a better method? Let us solve the congruence 23x 4 (mod 211). Do we need 211 tries?

38 Linear congruences Linear congruences Theorem (Solution of linear congruences) Let a, b, m be integers with m > 1. Then if there is a solution for ax b (mod m) (a, m) b. If this is the case, the number of incongruent solutions modulo m equals (a, m). Proof. ax b (mod m) ax + my = b for some y integer. (a, m) a and (a, m) m (a, m) ax + my = b. If d = (a, m) b let a = a/d, b = b/d, m = m/d: a x + m y = b Since (a, m ) = 1 using the extended euclidean algorithm we can calculate x 0, y 0, so a x 0 + m y 0 = 1 a (b x 0 ) + m (b y 0 ) = b, that is x 1 = b x 0, y 1 = b y 0 will be the solutions. Number of solutions: let (x, y) be a (pair of) solutions. Subtracting the equations equations a x + m y = b and

39 Linear congruences Linear 1. ax b (mod m) ax + my = b. 2. Let us solve the ax + my = (a, m) equation (ext. euc. alg.). 3. If (a, m) b a solution exists. 4. The solution: x i = b (a,m) x + k m (a,m): k = 0, 1,..., (a, m) 1. Example (Solving congruences) i r n q n x i Example (23x 4 (211)) r i 2 = r i 1 q i + r i, x 1 = 1, x 0 = 0, x i = x i 2 q i x i 1 GCD: (23, 211) = 1 4 One solution: x = 4( 55) 202 (mod 211). All solutions: { k : k Z}. These are solutions:

40 Linear congruences Linear congruences Example (Solving congruences) Solve the 10x 8 (mod 22) congruence! i r n q n x i The algorithm: r i 2 = r i 1 q i + r i, x 1 = 1, x 0 = 0, x i = x i 2 q i x i 1, y 1 = 0, y 0 = 1, y i = y i 2 q i y i 1 GCD: (10, 22) = 2 8 A pair of solutions: x 1 = 4( 2) 14 (mod 22), x 2 = 4( 2) (mod 22). All solutions: { k : k Z} {3 + 22k : k Z}.

41 Linear congruences Linear Diophantine equations Linear Diophantine equations Definition: equations with integer solutions. Linear Diophantine equations: ax + by = c, where a, b, c Z. This is equivalent with the ax c (mod b), or by c (mod a) congruence. ax + by = c can be solved if and only if (a, b) c, and then the solutions can be obtained using the extended euclidean algorithm. Other Diophantine equations x 2 + y 2 = 4: Doesn t have (real) solutions. x 2 4y 2 = 3: doesn t have integer solutions, because the remainders (mod 4) is: x 2 3 (mod 4). But this can not be, because the Squares (mod 4) x x 2 mod 4 4k 0 4k k k + 3 1

42 Simultaneous congruences Simultaneous congruences We want to find an integer x, which simultaneously satisfies the following congruences: 2x 1 (mod 3) 4x 3 (mod 5) The solution for the congruences separately: x 2 (mod 3) x 2 (mod 5) We can see x = 2 will be a solution! 2, 17, 32,...,2 + 15k; Other solutions? How do we solve the general case: x 2 (mod 3) x 3 (mod 5)

43 Simultaneous congruences Simultaneous congruences Problem: Solve the following system of congruences: a 1 x b 1 (mod m 1 ) a 2 x b 2 (mod m 2 ). a n x b n (mod m n ) The congruences a i x b i (mod m i ) can be solved separately: x c 1 (mod m 1 ) x c 2 (mod m 2 ). x c n (mod m n )

44 Simultaneous congruences Simultaneous congruences Problem: Solve the following system of congruences: x c 1 (mod m 1 ) x c 2 (mod m 2 ). x c n (mod m n ) We can assume that m 1, m 2..., m n are relative prime. If e.g. m 1 = m 1 d, m 2 = m 2 d, the first two congruences can be substituted with the following (Proof later) x c 1 (mod m 1) x c 1 (mod d) x c 2 (mod m 2) x c 2 (mod d)

45 Simultaneous congruences Chinese remainder theorem Theorem (Chinese remainder theorem) Let 1 < m 1, m 2..., m n be relative prime numbers, c 1, c 2,..., c n integers. Then the x c 1 (mod m 1 ) x c 2 (mod m 2 ). x c n (mod m n ) system of congruences can be solves, and the solutions are congruent to each other modulo m 1 m 2 m n.

46 Simultaneous congruences Chinese remainder theorem x c 1 (mod m 1 ), x c 2 (mod m 2 ),..., x c n (mod m n ). x =? Proof. Let m = m 1 m 2. Using the extended euclidean algorithm solve the m 1 x 1 + m 2 x 2 = 1 equation. Let c 1,2 = m 1 x 1 c 2 + m 2 x 2 c 1. Then c 1,2 c j (mod m j ) (j = 1, 2). If x c 1,2 (mod m), then x is the solution of the first two congruences. Converse: if x is a solution of the first two congruences, then m 1 and m 2 are divisors of x c 1,2, therefore their product is also a divisor: x c 1,2 (mod m). This gives us an equivalent system of congruences to the original: x c 1,2 (mod m 1 m 2 ) x c 3 (mod m 3 ). x c n (mod m n )

47 Simultaneous congruences Simultaneous congruences Example (Simultaneous congruences) Solve the following system of congruences: x 2 (mod 3) x 3 (mod 5) Let us solve the 3x 1 + 5x 2 = 1 equation. The solution: x 1 = 3, x 2 = 2 c 1,2 = 3 ( 3) = = 7. All the solutions: { k : k Z} = {8 + 15k : k Z}.

48 Simultaneous congruences Simultaneous congruences Example (Example) x 2 (mod 3) { c 1,2 =8 x 8 (mod 15) x 3 (mod 5) = x 4 (mod 7) x 4 (mod 7) Example (Example) Let us solve the 15x 1,2 + 7x 3 = 1 equation. Solutions: x 1,2 = 1, x 3 = 2. c 1,2,3 = ( 2) 8 = = 52. All the solutions: { l : l Z} = { l : l Z}.

49 Residue classes Residue classes Often, the solution is not just one integer (family of integers), but an entire set (set of families): 2x 5 (mod 7), sol.: {6 + 7k : k Z} 10x 8 (mod 22), sol.: { k : k Z}, {3 + 22k : k Z}. Definition (Residue classes) For a fixed modulus m and integer a, the integers congruent to a constitute the residue (or congruence) class represented by a: a = {x Z : x a (mod m)} = {a + km : k Z}. The set of all residue classes is denoted by Z m = {a : 0 a < m}. Example (Residue class) The solution of 2x 5 (mod 7): 6 The solution of 10x 8 (mod 22): 14, 3. With modulus m = 7, 2 = 23 = {..., 5, 2, 9, 16, 23, 30,... }

50 Residue classes Complete residue system Definition (Complete residue system) For a fixed modulus m, the complete residue system modulo m is a set containing exactly one element from each congruence class modulo m. Example (CRS) {33, 5, 11, 11, 8} is a complete residue system modulo 5. A popular choices for complete residue systems: Least non-negative residue system modulo m: {0, 1,..., m 1}; Least absolute value residue system modulo m: { } 0, ±1,..., ± m 1 { 2, if 2 m; 0, ±1,..., ± m 2 2, } m 2, if 2 m.

51 Residue classes Reduced residue system Remark If one element of a congruence class is relative prime to the modulus, then all the elements are too:: (a + lm, m) = (a, m) = 1. Definition (Reduced residue system) For a fixed modulus m, the reduced residue system modulo m is a set containing exactly one element from all the congruence classes with elements relative prime to m. For a fixed modulus m, if (a, m) = 1, then the residue class a represented by a is a reduced residue class. The set of reduced residue classes is denoted by Z m = {a : 1 a < m, (a, m) = 1}. Example (RRS) {1, 2, 3, 4} is a reduced residue system modulo 5. {1, 1} is a reduced residue system modulo 3. {1, 19, 29, 7} is a reduced residue system modulo 8.

52 Residue classes Operations on residue classes Operations between residue classes can be defined in a natural way: Definition (Addition and multiplication) For a fixed modulus m, and a, b integers let: a + b def = a + b; a b def = a b Proposition This definition is meaningful, because if a = a, b = b, then a + b = a + b, and a b = a b Proof. Since a = a, b = b a a (mod m), b b (mod m) a + b a + b (mod m) a + b = a + b a + b = a + b. Similar proof applies to the multiplication.

53 Residue classes Residue classes Operations between residue classes can be defined in a natural way: a + b = a + b; a b = a b. Definition (Operations) For a fixed modulus m, let Z m be the set of residue classes modulo m. Then addition and multiplication can be defined on this set. Example (Z 3, +) Example (Z 3, )

54 Residue classes Example Example (Z 4, +) Example (Z 4, )

55 Residue classes Residue classes Theorem (Multiplicative group) Let m > 1 be an integer. If 1 < (a, m) < m, then a is a zero divisor in Z m : for a there exists a b 0, so a b = 0 If (a, m) = 1, then a has a reciprocal (multiplicative inverse) in Z m : for a there exists a x, so a x = 1. Ergo, if m is prime, division by any non-zero prime is possible. Example (Zero divisors and multiplicative inverse) Let m = = 18 = 0. (2, 9) = 1, so 2 5 = 10 = 1. Proof. Let d = (a, m). Then a m d = a d m 0 (mod m), which if b = m/d then a b = 0. If (a, m) = 1, then using the ext.euc.alg. we can obtain x, y

56 Remark: ϕ(m) is the number of reduced congruence classes modulo m. Discrete mathematics I - Number theory Euler-Fermat theorem and the totient function Euler s totient ϕ function Definition (Totient function) For a m > 0 integer, let ϕ(m) be the number of positive integers less then and relative prime to m: ϕ(m) = {i : 0 < i < m, (m, i) = 1}. Example (Totient function) ϕ(5) = 4: integers relative prime to 5: 1, 2, 3, 4; ϕ(6) = 2: integers relative prime to 6: 1, 5; ϕ(12) = 4: integers relative prime to 12: 1, 5, 7, 11. ϕ(15) = 8: integers relative prime to 15: 1, 2, 4, 7, 8, 11, 13, 14.

57 Euler-Fermat theorem and the totient function Euler function ϕ(m) = {i : 0 < i < m, (m, i) = 1} Theorem (Calculating the ϕ(n)) Let the factorization of m be m = p e 1 1 pe 2 2 pe l l. Then l ϕ(m) = m (1 1 ) l = pi i=1 i=1 ( p e i i ) p e i 1 i = l i=1 p e i 1 i (p i 1) Example (Calculating the ϕ(n)) ( ) ϕ(5) = = 4; ( ) ( ) ϕ(6) = = 2; ( ) ( ) ϕ(12) = = 4; ( ) ( )

58 Euler-Fermat theorem and the totient function Euler-Fermat theorem Theorem (Euler-Fermat) Let m > 1 be an integer, a an integer for which (a, m) = 1. Then a ϕ(m) 1 (mod m). Theorem (Fermat) Let p be a prime, p a. Then a p 1 1 (mod p), or if is an arbitrary integer a then a p a (mod p). (A direct consequence of the E-F thm) Example (Euler Fermat theorem) ϕ(6) = = 25 1 (mod 6); ϕ(12) = = (mod 12); 7 4 = (mod 12). Caution! 2 4 = (mod 12), because (2, 12) = 2 1.

59 Euler-Fermat theorem and the totient function The proof of Euler-Fermat theorem Lemma Let m > 1 be an integer, a 1, a 2..., a m a complete residue system modulo m. Then for each integer a, b, if (a, m) = 1, then a a 1 + b, a a 2 + b..., a a m + b is also a complete residue system. Further, if a 1, a 2,..., a ϕ(m) is a reduced residue system modulo m, then a a 1, a a 2..., a a ϕ(m) is also a reduced residue system. Proof. If i j then aa i + b aa j + b (mod m) aa i aa j (mod m). Since (a, m) = 1, we divide by a: a i a j (mod m). So a a 1 + b, a a 2 + b..., a a m + b are pairwise incongruent. Since we have m different numbers, it is a complete residue system. If (a i, m) = 1, then (a, m) = 1 (a a i, m) = 1. Further a a 1, a a 2..., a a ϕ(m) are pairwise incongruent, their number is ϕ(m) reduced residue system.

60 Euler-Fermat theorem and the totient function The proof of Euler-Fermat theorem Theorem (Euler-Fermat) (a, m) = 1 a ϕ(m) 1 (mod m). Proof Let a 1, a 2,..., a ϕ(m) be a reduced residue system modulo m. Since (a, m) = 1 a a 1, a a 2..., a a ϕ(m) is also a reduced residue system. Therefore ϕ(m) a ϕ(m) j=1 a j = ϕ(m) j=1 a a j ϕ(m) j=1 a j (mod m) Because ϕ(m) j=1 a j is relative prime to m, we can simplify: a ϕ(m) 1 (mod m)

61 Euler-Fermat theorem and the totient function Euler-Fermat theorem Theorem (Euler-Fermat) (a, m) = 1 a ϕ(m) 1 (m) Example (E-F theorem) What is the last digit of in the decimal number system? What is mod 10? ϕ(10) = = = ( 3 4) = 27 7 (10) Solve the 2x 5 (mod 7) congruence! ϕ(7) = 6. Multiply both sides by 2 5. Then x x (mod 7). And now = = 20 6 (mod 7). Solve the 23x 4 (mod 211) congruence! ϕ(211) = 210. Multiply both sides by Then x x (mod 211). And now

62 Euler-Fermat theorem and the totient function Exponentiation by squaring (fast exponentiation) Let m, a, n be positive integers, m > 1. We would like to calculate efficiently the remainder a n mod m. Write n in the base 2 (binary) numeral system: k n = ε i 2 i = (ε k ε k 1... ε 1 ε 0 ) (2) where ε 0, ε 1,..., ε k {0, 1} i=0 Let n j (0 j k) be the number defined by the first j + 1 digits: n j = n/2 k j = (ε k ε k 1... ε k j+1 ) (2) Then for each j the remainder x j a n j (mod m): n 0 = ε 0 = 1, x 0 = a. n j = 2 n j 1 + ε j { x j = a ε j x xj mod m = j 1 mod m, if ε j = 0 a ε j xj 1 2 mod m, if ε j = 0 x k = a n mod m. The correctness follows from the following formula (Proof HW): n k ( 2 i ) εi k i

63 Euler-Fermat theorem and the totient function Fast exponentiation Example (Fast exponentiation) How much is mod 10? (Euler-Fermat 7) 111 (10) = (2) here k = 6, a = 3. j n j x j = a ε j xj 1 2 x j mod x 1 = x 2 = x 3 = x 4 = x 5 = x 6 =

64 209 Discrete mathematics I - Number theory Euler-Fermat theorem and the totient function Fast exponentiation Example (Lin.cong. with fast exponentiation) Let us solve the congruence 23x 4 (mod 211). Euler-Fermat x (mod 211). How much is mod 211? 209 (10) = (2) itt k = 7, a = 23. j n j x j = a ε j xj 1 2 x j mod x 1 = x 2 = x 3 = x 4 = x 5 = x 6 = x 6 =

65 The multiplicative group Generators Theorem (Generating the multiplicative group) Let p be a prime. Then in Z p there exists a generator (primitive root), i.e. there is an integer 1 < g < p, which yields every reduced congruence class when raised to different powers of integer: {g 0 = 1, g, g 2,..., g p 1 } = Z p, i.e. {1 = g 0, g mod p, g 2 mod p,..., g p 1 mod p} = {1, 2,..., p 1}. Example (3 is a generator modulo 7) 3 1 = 3 = = 3 3 mod = 9 = = 9 2 mod = 27 = = 6 6 mod = 81 = = 18 4 mod = 243 = = 12 5 mod = 729 = = 15 1 mod 7

66 The multiplicative group Generator Example (2 mod 11 and mod 7) 2 is a generator modulo 11 n n mod is not a generator modulo 7 n n mod

67 Discrete logarithm Discrete logarithm Definition (Discrete logarithm) Let p be a prime, g a generator modulo p. Then the a Z: (p a) g base discrete logarithm (or index) of a is: log g a = n : a g n mod p, 0 n < p 1. Example (3 is a gen. mod 7) n n n n Example (Discrete logarithm) a log 3 a a log 3 a

68 Discrete logarithm Discrete logarithm Example (a) 2 is a generator modulo 11 n n mod Table of logarithms: a log 2 a Theorem (Properties of the discrete logarithm) Let p be a prime, g a generator p, 1 a, b < p, n Z. Then log g (a b) log g a + log g b (mod p 1) n

69 Applications Applications Field of applications of number theory: Cryptography encryption of messages; digital signatures; authentication and authorization, Code theory

70 Applications Caesar cipher (code) Julius Caesar communicated with his soldiers using the following cipher: Let us match the letters of the (English) alphabet with the set {0, 1,..., 25} : a 0 b 1 c 2. z 25 Example (Caesar - Rot13) Encryption key s {0, 1,..., 25}. Encryption For a {0, 1,..., 25} encrypt a using the a a + s mod 26 map. The encryption is letter-wise. Decryption For b {0, 1,..., 25} decrypt b using the b a s mod 26 map. Decryption is letter-wise. Encryption of hello using s = 13 as the key: hello encryption uryyb

71 Applications Caesar cipher (code) For the key s = 13 we have: Rot13. Encryption and decryption is done with the same key: (mod 26). This cipher is not secure: it can be cracked by analyzing the frequency of occurrence of letters (al-kindi 9 century a.d. ) If we use a different (random) keys at different positions in the message security is mathematically proven. In practice: One Time Pad OTP Message: binary form: m = Key: binary sequence: s = Encryption: bitwise XOR (mod2 addition): m = XOR s = c =

72 RSA Applications Ron Rivest, Adi Shamir and Leonard Adleman suggested the following method in 1977: RSA encryption Generating the keys: Let p, q be two (big, ~1024 bit) primes, n = p q. Let e {1,..., ϕ(n)}, so that (e, ϕ(n)) = 1. Let d be the solution of the congruence ex 1 (mod ϕ(n)). Keys: public key (n, e) and private (secret) key d. Encryption of the message 0 m < n: c = m e mod n. Decryption for an encrypted message 0 c < n: m = c d mod n. Correctness of the algorithm E-F

73 RSA Applications Actually m just a key for another encryption. The procedure is secure, because we can not efficiently factorize the n = p q product. Problem Find the divisors of the following numbers. RSA-100 = RSA-2048 =

74 Applications RSA Factorization of RSA-2048: Trial-division (the sieve of Eratosthenes): for a number n about n divisions are needed: RSA , divisions. For divisions per second /2 30 = seconds are needed to factorise seconds years. The same with 2 computers: years. The same with the best (known) algorithm: years (= 2, ) The age of the universe: 1, years.

75 e and d change rolls (Separate keys are needed for encryption): Discrete mathematics I - Number theory RSA Applications Example (RSA) Generating the keys: Let p = 61, q = 53 and n = = 3233, ϕ(3233) = Let e = 17. Using the extended euclidean algorithm: d = 2753 Public key: (n = 3233, e = 17); Private (secret) key: d = Encryption: Let m = 65. c = (mod 3233) Decryption: If c = 2790: (mod 3233) Digital signature

76 Applications Diffie-Hellman key exchange protocol The first public key cryptography system was developed by Whitfield Diffie and Martin Hellman, and published in Alice Bob chooses: a R {0, 1,..., p 2} chooses: b R {0, 1,..., p 2} g a g b calculates: (g b) a calculates: (g a ) b common key: g ab common key: g ab Public parameters: p (large) prime, g generator modp. Keys: Alice s private key a: 1 a < p 1, public key g a mod p Bob s private key b: 1 a < p 1, public key g b mod p

77 Applications Diffie-Hellman key exchange protocol The protocol is secure, because calculating the discrete logarithm is hard. If p (2048 bits), calculating the discrete logarithm takes years. Example (Diffie-Hellman) Public parameters: Let p = 11, g = 2. Keys: Alice s private key a = 4, public key 2 4 mod p = 5 Bob private key b = 8, public key 2 8 mod p = 3 ( Common key: g b) a = 3 4 mod p = 4, (g a ) b = 5 8 mod = 4.

Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya

Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya BBM 205 Discrete Mathematics Hacettepe University http://web.cs.hacettepe.edu.tr/ bbm205 Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya Resources: Kenneth Rosen,

More information

Elementary Number Theory MARUCO. Summer, 2018

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

More information

CS March 17, 2009

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

More information

Elementary Number Theory Review. Franz Luef

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

More information

4 Number Theory and Cryptography

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.

More information

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

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,

More information

Number Theory: Applications. Number Theory Applications. Hash Functions II. Hash Functions III. Pseudorandom Numbers

Number Theory: Applications. Number Theory Applications. Hash Functions II. Hash Functions III. Pseudorandom Numbers Number Theory: Applications Number Theory Applications Computer Science & Engineering 235: Discrete Mathematics Christopher M. Bourke cbourke@cse.unl.edu Results from Number Theory have many applications

More information

CRYPTOGRAPHY AND NUMBER THEORY

CRYPTOGRAPHY AND NUMBER THEORY CRYPTOGRAPHY AND NUMBER THEORY XINYU SHI Abstract. In this paper, we will discuss a few examples of cryptographic systems, categorized into two different types: symmetric and asymmetric cryptography. We

More information

3 The fundamentals: Algorithms, the integers, and matrices

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

More information

Encryption: The RSA Public Key Cipher

Encryption: The RSA Public Key Cipher Encryption: The RSA Public Key Cipher Michael Brockway March 5, 2018 Overview Transport-layer security employs an asymmetric public cryptosystem to allow two parties (usually a client application and a

More information

CIS 551 / TCOM 401 Computer and Network Security

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

More information

Slides by Kent Seamons and Tim van der Horst Last Updated: Oct 1, 2013

Slides by Kent Seamons and Tim van der Horst Last Updated: Oct 1, 2013 RSA Slides by Kent Seamons and Tim van der Horst Last Updated: Oct 1, 2013 Recap Recap Number theory o What is a prime number? o What is prime factorization? o What is a GCD? o What does relatively prime

More information

Chapter 8 Public-key Cryptography and Digital Signatures

Chapter 8 Public-key Cryptography and Digital Signatures Chapter 8 Public-key Cryptography and Digital Signatures v 1. Introduction to Public-key Cryptography 2. Example of Public-key Algorithm: Diffie- Hellman Key Exchange Scheme 3. RSA Encryption and Digital

More information

ICS141: Discrete Mathematics for Computer Science I

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

More information

Discrete Mathematics GCD, LCM, RSA Algorithm

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

More information

Public Key Cryptography

Public Key Cryptography Public Key Cryptography Spotlight on Science J. Robert Buchanan Department of Mathematics 2011 What is Cryptography? cryptography: study of methods for sending messages in a form that only be understood

More information

Congruence of Integers

Congruence of Integers Congruence of Integers November 14, 2013 Week 11-12 1 Congruence of Integers Definition 1. Let m be a positive integer. For integers a and b, if m divides b a, we say that a is congruent to b modulo m,

More information

Ma/CS 6a Class 3: The RSA Algorithm

Ma/CS 6a Class 3: The RSA Algorithm Ma/CS 6a Class 3: The RSA Algorithm By Adam Sheffer Reminder: Putnam Competition Signup ends Wednesday 10/08. Signup sheets available in all Sloan classrooms, Math office, or contact Kathy Carreon, kcarreon@caltech.edu.

More information

Integers and Division

Integers and Division Integers and Division Notations Z: set of integers N : set of natural numbers R: set of real numbers Z + : set of positive integers Some elements of number theory are needed in: Data structures, Random

More information

Number Theory. Modular Arithmetic

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

More information

Ma/CS 6a Class 2: Congruences

Ma/CS 6a Class 2: Congruences Ma/CS 6a Class 2: Congruences 1 + 1 5 (mod 3) By Adam Sheffer Reminder: Public Key Cryptography Idea. Use a public key which is used for encryption and a private key used for decryption. Alice encrypts

More information

Public Key 9/17/2018. Symmetric Cryptography Review. Symmetric Cryptography: Shortcomings (1) Symmetric Cryptography: Analogy

Public Key 9/17/2018. Symmetric Cryptography Review. Symmetric Cryptography: Shortcomings (1) Symmetric Cryptography: Analogy Symmetric Cryptography Review Alice Bob Public Key x e K (x) y d K (y) x K K Instructor: Dr. Wei (Lisa) Li Department of Computer Science, GSU Two properties of symmetric (secret-key) crypto-systems: The

More information

CPSC 467b: Cryptography and Computer Security

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

More information

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

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

More information

Cryptography. P. Danziger. Transmit...Bob...

Cryptography. P. Danziger. Transmit...Bob... 10.4 Cryptography P. Danziger 1 Cipher Schemes A cryptographic scheme is an example of a code. The special requirement is that the encoded message be difficult to retrieve without some special piece of

More information

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

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

More information

OWO Lecture: Modular Arithmetic with Algorithmic Applications

OWO Lecture: Modular Arithmetic with Algorithmic Applications OWO Lecture: Modular Arithmetic with Algorithmic Applications Martin Otto Winter Term 2008/09 Contents 1 Basic ingredients 1 2 Modular arithmetic 2 2.1 Going in circles.......................... 2 2.2

More information

Asymmetric Encryption

Asymmetric Encryption -3 s s Encryption Comp Sci 3600 Outline -3 s s 1-3 2 3 4 5 s s Outline -3 s s 1-3 2 3 4 5 s s Function Using Bitwise XOR -3 s s Key Properties for -3 s s The most important property of a hash function

More information

10 Public Key Cryptography : RSA

10 Public Key Cryptography : RSA 10 Public Key Cryptography : RSA 10.1 Introduction The idea behind a public-key system is that it might be possible to find a cryptosystem where it is computationally infeasible to determine d K even if

More information

CPSC 467: Cryptography and Computer Security

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

More information

Topics in Cryptography. Lecture 5: Basic 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

More information

NUMBER THEORY AND CODES. Álvaro Pelayo WUSTL

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

More information

A Readable Introduction to Real Mathematics

A Readable Introduction to Real Mathematics Solutions to selected problems in the book A Readable Introduction to Real Mathematics D. Rosenthal, D. Rosenthal, P. Rosenthal Chapter 7: The Euclidean Algorithm and Applications 1. Find the greatest

More information

Applied Cryptography and Computer Security CSE 664 Spring 2018

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

More information

Definition: For a positive integer n, if 0<a<n and gcd(a,n)=1, a is relatively prime to n. Ahmet Burak Can Hacettepe University

Definition: For a positive integer n, if 0<a<n and gcd(a,n)=1, a is relatively prime to n. Ahmet Burak Can Hacettepe University Number Theory, Public Key Cryptography, RSA Ahmet Burak Can Hacettepe University abc@hacettepe.edu.tr The Euler Phi Function For a positive integer n, if 0

More information

Review. CS311H: Discrete Mathematics. Number Theory. Computing GCDs. Insight Behind Euclid s Algorithm. Using this Theorem. Euclidian Algorithm

Review. CS311H: Discrete Mathematics. Number Theory. Computing GCDs. Insight Behind Euclid s Algorithm. Using this Theorem. Euclidian Algorithm Review CS311H: Discrete Mathematics Number Theory Instructor: Işıl Dillig What does it mean for two ints a, b to be congruent mod m? What is the Division theorem? If a b and a c, does it mean b c? What

More information

Ma/CS 6a Class 2: Congruences

Ma/CS 6a Class 2: Congruences Ma/CS 6a Class 2: Congruences 1 + 1 5 (mod 3) By Adam Sheffer Reminder: Public Key Cryptography Idea. Use a public key which is used for encryption and a private key used for decryption. Alice encrypts

More information

Carmen s Core Concepts (Math 135)

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

More information

Number Theory & Modern Cryptography

Number Theory & Modern Cryptography Number Theory & Modern Cryptography Week 12 Stallings: Ch 4, 8, 9, 10 CNT-4403: 2.April.2015 1 Introduction Increasing importance in cryptography Public Key Crypto and Signatures Concern operations on

More information

Numbers. Çetin Kaya Koç Winter / 18

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

More information

ECE596C: Handout #11

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

More information

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

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

More information

Introduction to Cryptography. Lecture 6

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:

More information

INTEGERS. In this section we aim to show the following: Goal. Every natural number can be written uniquely as a product of primes.

INTEGERS. In this section we aim to show the following: Goal. Every natural number can be written uniquely as a product of primes. INTEGERS PETER MAYR (MATH 2001, CU BOULDER) In this section we aim to show the following: Goal. Every natural number can be written uniquely as a product of primes. 1. Divisibility Definition. Let a, b

More information

Number theory (Chapter 4)

Number theory (Chapter 4) EECS 203 Spring 2016 Lecture 12 Page 1 of 8 Number theory (Chapter 4) Review Compute 6 11 mod 13 in an efficient way What is the prime factorization of 100? 138? What is gcd(100, 138)? What is lcm(100,138)?

More information

RSA. Ramki Thurimella

RSA. Ramki Thurimella RSA Ramki Thurimella Public-Key Cryptography Symmetric cryptography: same key is used for encryption and decryption. Asymmetric cryptography: different keys used for encryption and decryption. Public-Key

More information

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

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

More information

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

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

More information

Mathematics of Cryptography

Mathematics of Cryptography UNIT - III Mathematics of Cryptography Part III: Primes and Related Congruence Equations 1 Objectives To introduce prime numbers and their applications in cryptography. To discuss some primality test algorithms

More information

Math.3336: Discrete Mathematics. Mathematical Induction

Math.3336: Discrete Mathematics. Mathematical Induction Math.3336: Discrete Mathematics Mathematical Induction Instructor: Dr. Blerina Xhabli Department of Mathematics, University of Houston https://www.math.uh.edu/ blerina Email: blerina@math.uh.edu Fall 2018

More information

Summary Slides for MATH 342 June 25, 2018

Summary Slides for MATH 342 June 25, 2018 Summary Slides for MATH 342 June 25, 2018 Summary slides based on Elementary Number Theory and its applications by Kenneth Rosen and The Theory of Numbers by Ivan Niven, Herbert Zuckerman, and Hugh Montgomery.

More information

Eindhoven University of Technology MASTER. Kleptography cryptography with backdoors. Antheunisse, M. Award date: 2015

Eindhoven University of Technology MASTER. Kleptography cryptography with backdoors. Antheunisse, M. Award date: 2015 Eindhoven University of Technology MASTER Kleptography cryptography with backdoors Antheunisse, M. Award date: 2015 Disclaimer This document contains a student thesis (bachelor's or master's), as authored

More information

Mathematical Foundations of Public-Key Cryptography

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

More information

Introduction to Modern Cryptography. Benny Chor

Introduction to Modern Cryptography. Benny Chor Introduction to Modern Cryptography Benny Chor RSA Public Key Encryption Factoring Algorithms Lecture 7 Tel-Aviv University Revised March 1st, 2008 Reminder: The Prime Number Theorem Let π(x) denote the

More information

Basic elements of number theory

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

More information

Basic elements of number theory

Basic elements of number theory 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

More information

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

More information

Introduction to Public-Key Cryptosystems:

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

More information

LECTURE 5: APPLICATIONS TO CRYPTOGRAPHY AND COMPUTATIONS

LECTURE 5: APPLICATIONS TO CRYPTOGRAPHY AND COMPUTATIONS LECTURE 5: APPLICATIONS TO CRYPTOGRAPHY AND COMPUTATIONS Modular arithmetics that we have discussed in the previous lectures is very useful in Cryptography and Computer Science. Here we discuss several

More information

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

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ī

More information

Cryptography. Course 1: Remainder: RSA. Jean-Sébastien Coron. September 21, Université du Luxembourg

Cryptography. Course 1: Remainder: RSA. Jean-Sébastien Coron. September 21, Université du Luxembourg Course 1: Remainder: RSA Université du Luxembourg September 21, 2010 Public-key encryption Public-key encryption: two keys. One key is made public and used to encrypt. The other key is kept private and

More information

Public-Key Cryptosystems CHAPTER 4

Public-Key Cryptosystems CHAPTER 4 Public-Key Cryptosystems CHAPTER 4 Introduction How to distribute the cryptographic keys? Naïve Solution Naïve Solution Give every user P i a separate random key K ij to communicate with every P j. Disadvantage:

More information

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer?

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer? Chapter 3: Theory of Modular Arithmetic 25 SECTION C Solving Linear Congruences By the end of this section you will be able to solve congruence equations determine the number of solutions find the multiplicative

More information

My brief introduction to cryptography

My brief introduction to cryptography My brief introduction to cryptography David Thomson dthomson@math.carleton.ca Carleton University September 7, 2013 introduction to cryptography September 7, 2013 1 / 28 Outline 1 The general framework

More information

MATHEMATICS EXTENDED ESSAY

MATHEMATICS EXTENDED ESSAY MATHEMATICS EXTENDED ESSAY How does the RSA algorithm function and why is it used in modern communication? Candidate Name: Murtuza Kainan Candidate Session Number: 003077006 Word Count: 3908 1 P a g e

More information

Chapter 5. Number Theory. 5.1 Base b representations

Chapter 5. Number Theory. 5.1 Base b representations Chapter 5 Number Theory The material in this chapter offers a small glimpse of why a lot of facts that you ve probably nown and used for a long time are true. It also offers some exposure to generalization,

More information

Public Key Algorithms

Public Key Algorithms Public Key Algorithms Raj Jain Washington University in Saint Louis Saint Louis, MO 63130 Jain@cse.wustl.edu Audio/Video recordings of this lecture are available at: http://www.cse.wustl.edu/~jain/cse571-09/

More information

Fall 2017 September 20, Written Homework 02

Fall 2017 September 20, Written Homework 02 CS1800 Discrete Structures Profs. Aslam, Gold, & Pavlu Fall 2017 September 20, 2017 Assigned: Wed 20 Sep 2017 Due: Fri 06 Oct 2017 Instructions: Written Homework 02 The assignment has to be uploaded to

More information

EE4.07 Coding Theory

EE4.07 Coding Theory EE4.07 Coding Theory W. Dai Imperial College London (IC) 2017 W. Dai (IC) EE4.07 Coding Theory 2017 page 0-1 Syllabus Instructor: Dr. Wei Dai Lectures: Monday 16:00-17:00, 509B (Wks 2-11, 09/10/2017-11/12/2017)

More information

Introduction to Number Theory

Introduction to Number Theory INTRODUCTION Definition: Natural Numbers, Integers Natural numbers: N={0,1,, }. Integers: Z={0,±1,±, }. Definition: Divisor If a Z can be writeen as a=bc where b, c Z, then we say a is divisible by b or,

More information

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

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

More information

Clock Arithmetic and Euclid s Algorithm

Clock Arithmetic and Euclid s Algorithm Clock Arithmetic and Euclid s Algorithm Lecture notes for Access 2008 by Erin Chamberlain. Earlier we discussed Caesar Shifts and other substitution ciphers, and we saw how easy it was to break these ciphers

More information

Cryptography. pieces from work by Gordon Royle

Cryptography. pieces from work by Gordon Royle Cryptography pieces from work by Gordon Royle The set-up Cryptography is the mathematics of devising secure communication systems, whereas cryptanalysis is the mathematics of breaking such systems. We

More information

Elementary Number Theory and Cryptography, 2014

Elementary Number Theory and Cryptography, 2014 Elementary Number Theory and Cryptography, 2014 1 Basic Properties of the Integers Z and the rationals Q. Notation. By Z we denote the set of integer numbers and by Q we denote the set of rational numbers.

More information

Biomedical Security. Some Security News 9/17/2018. Erwin M. Bakker. Blockchains are not safe for voting (slashdot.org) : From: paragonie.

Biomedical Security. Some Security News 9/17/2018. Erwin M. Bakker. Blockchains are not safe for voting (slashdot.org) : From: paragonie. Biomedical Security Erwin M. Bakker Some Security News From: NYTimes Blockchains are not safe for voting (slashdot.org) : From Motherboard.vice.com ECDAA: Eliptic Curve Direct Anonymous Attestation for

More information

CPSC 467b: Cryptography and Computer Security

CPSC 467b: Cryptography and Computer Security CPSC 467b: Cryptography and Computer Security Michael J. Fischer Lecture 9 February 14, 2013 CPSC 467b, Lecture 9 1/42 Integer Division (cont.) Relatively prime numbers, Z n, and φ(n) Computing in Z n

More information

Number Theory A focused introduction

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

More information

7.2 Applications of Euler s and Fermat s Theorem.

7.2 Applications of Euler s and Fermat s Theorem. 7.2 Applications of Euler s and Fermat s Theorem. i) Finding and using inverses. From Fermat s Little Theorem we see that if p is prime and p a then a p 1 1 mod p, or equivalently a p 2 a 1 mod p. This

More information

CPSC 467: Cryptography and Computer Security

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

More information

2. Cryptography 2.5. ElGamal cryptosystems and Discrete logarithms

2. Cryptography 2.5. ElGamal cryptosystems and Discrete logarithms CRYPTOGRAPHY 19 Cryptography 5 ElGamal cryptosystems and Discrete logarithms Definition Let G be a cyclic group of order n and let α be a generator of G For each A G there exists an uniue 0 a n 1 such

More information

Security II: Cryptography exercises

Security II: Cryptography exercises Security II: Cryptography exercises Markus Kuhn Lent 2015 Part II Some of the exercises require the implementation of short programs. The model answers use Perl (see Part IB Unix Tools course), but you

More information

SOLUTIONS TO PROBLEM SET 1. Section = 2 3, 1. n n + 1. k(k + 1) k=1 k(k + 1) + 1 (n + 1)(n + 2) n + 2,

SOLUTIONS TO PROBLEM SET 1. Section = 2 3, 1. n n + 1. k(k + 1) k=1 k(k + 1) + 1 (n + 1)(n + 2) n + 2, SOLUTIONS TO PROBLEM SET 1 Section 1.3 Exercise 4. We see that 1 1 2 = 1 2, 1 1 2 + 1 2 3 = 2 3, 1 1 2 + 1 2 3 + 1 3 4 = 3 4, and is reasonable to conjecture n k=1 We will prove this formula by induction.

More information

Overview. Background / Context. CSC 580 Cryptography and Computer Security. March 21, 2017

Overview. Background / Context. CSC 580 Cryptography and Computer Security. March 21, 2017 CSC 580 Cryptography and Computer Security Math for Public Key Crypto, RSA, and Diffie-Hellman (Sections 2.4-2.6, 2.8, 9.2, 10.1-10.2) March 21, 2017 Overview Today: Math needed for basic public-key crypto

More information

Security Issues in Cloud Computing Modern Cryptography II Asymmetric Cryptography

Security Issues in Cloud Computing Modern Cryptography II Asymmetric Cryptography Security Issues in Cloud Computing Modern Cryptography II Asymmetric Cryptography Peter Schwabe October 21 and 28, 2011 So far we assumed that Alice and Bob both have some key, which nobody else has. How

More information

Lecture 14: Hardness Assumptions

Lecture 14: Hardness Assumptions CSE 594 : Modern Cryptography 03/23/2017 Lecture 14: Hardness Assumptions Instructor: Omkant Pandey Scribe: Hyungjoon Koo, Parkavi Sundaresan 1 Modular Arithmetic Let N and R be set of natural and real

More information

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

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

More information

CISC-102 Fall 2017 Week 6

CISC-102 Fall 2017 Week 6 Week 6 page 1! of! 15 CISC-102 Fall 2017 Week 6 We will see two different, yet similar, proofs that there are infinitely many prime numbers. One proof would surely suffice. However, seeing two different

More information

Theme : Cryptography. Instructor : Prof. C Pandu Rangan. Speaker : Arun Moorthy CS

Theme : Cryptography. Instructor : Prof. C Pandu Rangan. Speaker : Arun Moorthy CS 1 C Theme : Cryptography Instructor : Prof. C Pandu Rangan Speaker : Arun Moorthy 93115 CS 2 RSA Cryptosystem Outline of the Talk! Introduction to RSA! Working of the RSA system and associated terminology!

More information

Candidates must show on each answer book the type of calculator used. Only calculators permitted under UEA Regulations may be used.

Candidates must show on each answer book the type of calculator used. Only calculators permitted under UEA Regulations may be used. UNIVERSITY OF EAST ANGLIA School of Mathematics May/June UG Examination 2010 2011 CRYPTOGRAPHY Time allowed: 2 hours Attempt THREE questions. Candidates must show on each answer book the type of calculator

More information

Congruence Classes. Number Theory Essentials. Modular Arithmetic Systems

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

More information

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

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

More information

A Guide to Arithmetic

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

More information

4 PRIMITIVE ROOTS Order and Primitive Roots The Index Existence of primitive roots for prime modulus...

4 PRIMITIVE ROOTS Order and Primitive Roots The Index Existence of primitive roots for prime modulus... PREFACE These notes have been prepared by Dr Mike Canfell (with minor changes and extensions by Dr Gerd Schmalz) for use by the external students in the unit PMTH 338 Number Theory. This booklet covers

More information

RSA: Genesis, Security, Implementation & Key Generation

RSA: Genesis, Security, Implementation & Key Generation ECE 646 Lecture 8 RSA: Genesis, Security, Implementation & Key Generation Public Key (Asymmetric) Cryptosystems Public key of Bob - K B Private key of Bob - k B Network Alice Encryption Decryption Bob

More information

ECE 646 Lecture 8. RSA: Genesis, Security, Implementation & Key Generation

ECE 646 Lecture 8. RSA: Genesis, Security, Implementation & Key Generation ECE 646 Lecture 8 RSA: Genesis, Security, Implementation & Key Generation Public Key (Asymmetric) Cryptosystems Public key of Bob - K B Private key of Bob - k B Network Alice Encryption Decryption Bob

More information

Great Theoretical Ideas in Computer Science

Great Theoretical Ideas in Computer Science 15-251 Great Theoretical Ideas in Computer Science Lecture 22: Cryptography November 12th, 2015 What is cryptography about? Adversary Eavesdropper I will cut your throat I will cut your throat What is

More information

Homework #2 solutions Due: June 15, 2012

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

More information

Applied Cryptography and Computer Security CSE 664 Spring 2017

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

More information

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer?

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer? Chapter 3: Theory of Modular Arithmetic 25 SECTION C Solving Linear Congruences By the end of this section you will be able to solve congruence equations determine the number of solutions find the multiplicative

More information

Basic Algorithms in Number Theory

Basic Algorithms in Number Theory Basic Algorithms in Number Theory Algorithmic Complexity... 1 Basic Algorithms in Number Theory Francesco Pappalardi #2-b - Euclidean Algorithm. September 2 nd 2015 SEAMS School 2015 Number Theory and

More information