Ma/CS 6a Class 2: Congruences

Similar documents
Ma/CS 6a Class 2: Congruences

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

Ma/CS 6a Class 3: The RSA Algorithm

Ma/CS 6a Class 1. Course Details

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

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

Carmen s Core Concepts (Math 135)

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

Lecture Notes. Advanced Discrete Structures COT S

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

ECE596C: Handout #11

Elementary Number Theory MARUCO. Summer, 2018

Public Key Cryptography

M381 Number Theory 2004 Page 1

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

basics of security/cryptography

Congruence of Integers

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

Discrete Mathematics GCD, LCM, RSA Algorithm

Solution Sheet (i) q = 5, r = 15 (ii) q = 58, r = 15 (iii) q = 3, r = 7 (iv) q = 6, r = (i) gcd (97, 157) = 1 = ,

ICS141: Discrete Mathematics for Computer Science I

Discrete mathematics I - Number theory

A Readable Introduction to Real Mathematics

NOTES ON SIMPLE NUMBER THEORY

3.2 Solving linear congruences. v3

Introduction to Public-Key Cryptosystems:

1 Recommended Reading 1. 2 Public Key/Private Key Cryptography Overview RSA Algorithm... 2

CHAPTER 6. Prime Numbers. Definition and Fundamental Results

10 Modular Arithmetic and Cryptography

Wilson s Theorem and Fermat s Little Theorem

Number theory. Myrto Arapinis School of Informatics University of Edinburgh. October 9, /29

Homework #2 solutions Due: June 15, 2012

Number theory (Chapter 4)

Math 109 HW 9 Solutions

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

PUTNAM TRAINING NUMBER THEORY. Exercises 1. Show that the sum of two consecutive primes is never twice a prime.

Discrete Mathematics with Applications MATH236

Topics in Cryptography. Lecture 5: Basic Number Theory

CS2800 Questions selected for fall 2017

Introduction to Cryptography. Lecture 6

Math.3336: Discrete Mathematics. Mathematical Induction

Ma/CS 6a Class 4: Primality Testing

Integers and Division

Elementary Number Theory Review. Franz Luef

8 Primes and Modular Arithmetic

MATH 145 Algebra, Solutions to Assignment 4

Number Theory and Group Theoryfor Public-Key Cryptography

1. multiplication is commutative and associative;

Induction. Induction. Induction. Induction. Induction. Induction 2/22/2018

MATH 501 Discrete Mathematics. Lecture 6: Number theory. German University Cairo, Department of Media Engineering and Technology.

Simultaneous Linear, and Non-linear Congruences

Beautiful Mathematics

1 Overview and revision

Chapter 8 Public-key Cryptography and Digital Signatures

Chapter 3 Basic Number Theory

Cryptography: Joining the RSA Cryptosystem

Math.3336: Discrete Mathematics. Primes and Greatest Common Divisors

Mathematical Foundations of Public-Key Cryptography

12x + 18y = 50. 2x + v = 12. (x, v) = (6 + k, 2k), k Z.

CPSC 467b: Cryptography and Computer Security

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

CPSC 467b: Cryptography and Computer Security

NORTHWESTERN UNIVERSITY Thrusday, Oct 6th, 2011 ANSWERS FALL 2011 NU PUTNAM SELECTION TEST

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

Introduction to Number Theory

Wednesday, February 21. Today we will begin Course Notes Chapter 5 (Number Theory).

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

Linear Congruences. The equation ax = b for a, b R is uniquely solvable if a 0: x = b/a. Want to extend to the linear congruence:

CS March 17, 2009

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

7. Prime Numbers Part VI of PJE

CS 5319 Advanced Discrete Structure. Lecture 9: Introduction to Number Theory II

MATH 215 Final. M4. For all a, b in Z, a b = b a.

3 The fundamentals: Algorithms, the integers, and matrices

2 Arithmetic. 2.1 Greatest common divisors. This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}.

MEETING 6 - MODULAR ARITHMETIC AND INTRODUCTORY CRYPTOGRAPHY

Math 511, Algebraic Systems, Fall 2017 July 20, 2017 Edition. Todd Cochrane

An Algorithm for Prime Factorization

Introduction to Sets and Logic (MATH 1190)

Ma/CS 6a Class 4: Primality Testing

The security of RSA (part 1) The security of RSA (part 1)

ECE 646 Lecture 5. Mathematical Background: Modular Arithmetic

Discrete Logarithms. Let s begin by recalling the definitions and a theorem. Let m be a given modulus. Then the finite set

2.2 Inverses and GCDs

A Guide to Arithmetic

Senior Math Circles Cryptography and Number Theory Week 2

2301 Assignment 1 Due Friday 19th March, 2 pm

Instructor: Bobby Kleinberg Lecture Notes, 25 April The Miller-Rabin Randomized Primality Test

A field F is a set of numbers that includes the two numbers 0 and 1 and satisfies the properties:

CSE 20 DISCRETE MATH. Winter

4 Number Theory and Cryptography

Number Theory Math 420 Silverman Exam #1 February 27, 2018

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

Numbers, Groups and Cryptography. Gordan Savin

Number Theory Homework.

Congruence Classes. Number Theory Essentials. Modular Arithmetic Systems

Introduction to Cryptology. Lecture 19

NUMBER THEORY AND CODES. Álvaro Pelayo WUSTL

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

Public-Key Cryptosystems CHAPTER 4

Transcription:

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 her message with Bob s public key and sends it. Encrypts Message to Bob Decrypts Alice Bob 1

Reminder 2: The Euclidean Algorithm Input. Two numbers a, b N. Output. GCD a, b. r a mod b. While r 0: a b. b r. r a mod b. Output b. a = 78 b = 45 a = 78 b = 45 r = 33 a = 45 b = 33 r = 12 a = 33 b = 12 r = 9 a = 12 b = 9 r = 3 a = 9 b = 3 r = 0 Warm-up: The Fibonacci Numbers Fibonacci numbers: F 0 = F 1 = 1 F i = F i 1 + F i 2. 1,1,2,3,5,8,13,21,34, How many rounds of the algorithm are required to compute GCD F n, F n 1? 2

Warm-up: The Fibonacci Numbers Fibonacci numbers: F 0 = F 1 = 1 F i = F i 1 + F i 2. 1,1,2,3,5,8,13,21,34, How many rounds of the algorithm are required to compute GCD F n, F n 1? Round 1: r = F n F n 1 = F n 2. Round 2: r = F n 1 F n 2 = F n 3. Round n: r = F 1 F 0 = 0. More GCDs Theorem. For any a, b N, there exist s, t Z such that GCD a, b = as + bt. GCD 18,27 = 9 1 18 + 1 27 = 9 GCD 25,65 = 5 8 25 3 65 = 5 3

The Extended Euclidean Algorithm Build a matrix: First two rows are a, 1,0 and b, 0,1. Every other row is obtained by subtracting the two rows above it, to obtain the next value of b. 78 1 0 45 0 1 33 1 1 12 1 2 9 3 5 3 4 7 a = 78 b = 45 a = 78 b = 45 r = 33 a = 45 b = 33 r = 12 a = 33 b = 12 r = 9 a = 12 b = 9 r = 3 a = 9 b = 3 r = 0 The Extended Euclidean Algorithm Build a matrix: First two rows are a, 1,0 and b, 0,1. Every other row is obtained by subtracting the two rows above it, to obtain the next value of b. 78 1 0 45 0 1 33 1 1 12 1 2 9 3 5 3 4 7 In every step, we have a = qb + r, and then a b, b r. If R i denotes the i th row: R i = R i 2 qr i 1. 4

The Extended Euclidean Algorithm Build a matrix: First two rows are a, 1,0 and b, 0,1. Every other row is obtained by subtracting the two rows above it, to obtain the next value of b. 78 1 0 45 0 1 33 1 1 12 1 2 9 3 5 3 4 7 33 = 2 12 + 9 so R 5 = R 3 2R 4 Proof by Algorithm! Theorem. If c = GCD(a, b), then there exist s, t Z such that as + bt = c. 78 1 0 45 0 1 33 1 1 12 1 2 9 3 5 3 4 7 78 = 1 78 + 0 45 45 = 0 78 + 1 45 33 = 1 78 1 45 12 = 1 78 + 2 45 9 = 3 78 5 45 3 = 4 78 + 7 45 5

Algorithm Correctness Proof Sketch. By induction. Induction basis. Trivial for the first two rows. Induction step. R i R i+1 = R i+2 s 1 s 2 s 3 t 1 t 2 t 3 u 1 u 2 u 3 s 1 = a s 2 + b s 3, t 1 = a t 2 + b t 3, u 1 = s 1 qt 1 = a s 2 qt 2 + b s 3 qt 3 = a u 2 + b u 3. Induction hypothesis Scales Problem We need to verify the weights of various objects by using scales. We have an unlimited amount of weights in two different integer sizes - a and b. For which values of a and b can we measure every possible integer weight? Answer. Whenever GCD a, b = 1. 6

Number Theory Number theory: the study of integers. Some famous theorems: Euclid. There are infinitely many prime numbers. Fermat s last theorem. The equation x n + y n = z n has no integer solutions when n > 2. Lagrange 1770. Every natural number can be represented as the sum of four integer squares. 15 = 1 2 + 1 2 + 2 2 + 3 2 110 = 10 2 + 3 2 + 1 2 + 0 2 Number Theory (2) A couple of famous open problems: Twin prime conjecture. There are infinitely many pairs of prime numbers that differ by two (5 and 7, 17 and 19, 41 and 43, ). Goldbach's conjecture. Every even integer greater than 2 can be expressed as the sum of two primes. 7

Congruences Recall. The remainder of dividing a by m can be written as r = a mod m. If also r = b mod m, we say that a is congruent to b modulo m, and write a b mod m. Equivalently, m a b. The numbers 3, 10, 17, 73, 1053 are all congruent modulo 7. Congruence Classes If m = 2, numbers are congruent if they have the same parity. If m = 3, there are three distinct classes of numbers 0 3 6 9 mod 3 1 4 7 10 mod 3 2 5 8 11 mod 3 In general, we have exactly m equivalence classes of numbers. 8

Congruency is Transitive Claim 1. If a b mod m and b c mod m then a c mod m. 5 55 mod 10. 55 95 mod 10 5 95 mod 10 Congruency is Transitive Claim 1. If a b mod m and b c mod m then a c mod m. Proof. If m (a b) and m b c then m a c since a c = a b + b c. 9

Congruency and Addition Claim 2. If a b mod m and c d mod m, then a + c b + d mod m. 3 15 mod 12 2 26 mod 12 3 + 2 15 + 26 mod 12 Congruency and Addition Claim 2. If a b mod m and c d mod m, then a + c b + d mod m. Proof. If m a b and m c d then m a + c (b + d). 10

Congruency and Multiplication Claim 3. If a b mod m and c d mod m, then ac bd mod m. 3 15 mod 12 2 26 mod 12 3 2 15 26 mod 12 Congruency and Multiplication Claim 3. If a b mod m and c d mod m, then ac bd mod m. Proof. We have ac bd = ac cb + cb bd = c a b + b c d. That is, m ac bd. 11

Relatively Prime Numbers Two integers m, n Z are relatively prime if GCD m, n = 1. Claim 4. If a and m are relatively prime, then there exists b Z such that ab 1 mod m. GCD 6,17 = 1 6 3 = 1 mod 17 Relatively Prime Numbers Two integers m, n Z are relatively prime if GCD m, n = 1. Claim 4. If a and m are relatively prime, then there exists b Z such that ab 1 mod m. Proof. There exist s, t Z such that as + mt = 1. Taking b = s, we have m ab + mt 1 m ab 1. 12

A Cancellation Law Claim 5. If k, m are relatively prime, and ak bk mod m, then a b mod m. GCD 5,9 = 1 1 5 10 5 mod 9 1 10 mod 9 A Cancellation Law Claim 5. If k, m are relatively prime and ak bk mod m, then a b mod m. Proof. By Claim 4 there exist s Z such that ks 1 mod m. a a 1 aks bks b 1 b mod m. 13

A Cancellation Law Claim 5. If k, m are relatively prime and ak bk mod m, then a b mod m. What happens when GCD k, m 1? k = 4 m = 8 2 k 4 k 0 mod 8 Latin Squares Claim 6. Let a, b, m Z and let a, m be relatively prime. Then there is a unique x (mod m) such that ax b mod m. m = 11, a = 5, b = 6 5 x 6 mod 11 x = 10. 14

Latin Squares Claim 6. Let a, b, m Z and let a, m be relatively prime. Then there is a unique x (mod m) such that ax b mod m. Proof. By Claim 4 there exists s Z such that as 1 mod m. Thus, x = sb is one valid solution. Assume, for contradiction, that there are two distinct solutions x, x. Then ax ax mod m. x = sax = sax = x. Problem: Large Powers Problem. Compute 3 100 mod 7. 15

Problem: Large Powers Problem. Compute 3 100 mod 7. Modest beginning. 3 1 3 mod 7 3 2 3 3 1 2 mod 7 3 3 3 3 2 6 mod 7 3 4 3 3 3 4 mod 7 3 5 3 3 4 5 mod 7 3 6 3 3 5 1 mod 7 3 7 3 3 6 3 mod 7 Problem: Large Powers 3 1 3 mod 7 3 2 3 3 1 2 mod 7 3 3 3 3 2 6 mod 7 3 4 3 3 3 4 mod 7 3 5 3 3 4 5 mod 7 3 6 3 3 5 1 mod 7 3 7 3 3 6 3 mod 7 3 8 3 3 7 2 mod 7 3 100 3 4+6 16 3 4 1 4 mod 7 16

The End The famous number theorist G. H. Hardy in 1941: Real mathematics has no effects on war. No one has yet discovered any warlike purpose to be served by the theory of numbers and it seems unlikely that anyone will do so for many years. 1970 s: number theory becomes the main tool of modern cryptography. 17