COMP 170 L2 Page 1 L05: Inverses and GCDs l Objective: n When does have an inverse? n How to compute the inverse? n Need: Greatest common dividers (GCDs)

Slides:



Advertisements
Similar presentations
1 Lect. 12: Number Theory. Contents Prime and Relative Prime Numbers Modular Arithmetic Fermat’s and Euler’s Theorem Extended Euclid’s Algorithm.
Advertisements

COMP 170 L2 Page 1 L06: The RSA Algorithm l Objective: n Present the RSA Cryptosystem n Prove its correctness n Discuss related issues.
Cryptography and Network Security
Primality Testing Patrick Lee 12 July 2003 (updated on 13 July 2003)
Chapter Primes and Greatest Common Divisors ‒Primes ‒Greatest common divisors and least common multiples 1.
Basic properties of the integers
Math 3121 Abstract Algebra I
1 The RSA Algorithm Supplementary Notes Prepared by Raymond Wong Presented by Raymond Wong.
CSC2110 Discrete Mathematics Tutorial 5 GCD and Modular Arithmetic
Elementary Number Theory and Methods of Proof. Basic Definitions An integer n is an even number if there exists an integer k such that n = 2k. An integer.
Chapter II. THE INTEGERS
6/20/2015 5:05 AMNumerical Algorithms1 x x1x
Inverses and GCDs Supplementary Notes Prepared by Raymond Wong
Discrete Structures Chapter 2 Part B Mathematical Induction
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
Great Theoretical Ideas in Computer Science.
CSE 311 Foundations of Computing I Lecture 12 Primes, GCD, Modular Inverse Spring
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
Introduction Dr. Ying Lu RAIK 283: Data Structures & Algorithms.
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
Great Theoretical Ideas in Computer Science.
1 Properties of Integers Objectives At the end of this unit, students should be able to: State the division algorithm Apply the division algorithm Find.
9/2/2015Discrete Structures1 Let us get into… Number Theory.
Mathematics of Cryptography Part I: Modular Arithmetic
Module :MA3036NI Cryptography and Number Theory Lecture Week 7
Mathematics of Cryptography Modular Arithmetic, Congruence,
Prelude to Public-Key Cryptography Rocky K. C. Chang, February
The Integers. The Division Algorithms A high-school question: Compute 58/17. We can write 58 as 58 = 3 (17) + 7 This forms illustrates the answer: “3.
Modular Arithmetic with Applications to Cryptography Lecture 47 Section 10.4 Wed, Apr 13, 2005.
COMP 170 L2 Page 1 Review for Midterm 1 l Part I: Counting n L01-L03 l Part II: Number Theory and Cryptography n L04, L05.
Copyright © Zeph Grunschlag, Basic Number Theory Zeph Grunschlag.
YSLInformation Security -- Public-Key Cryptography1 Prime and Relatively Prime Numbers Divisors: We say that b  0 divides a if a = mb for some m, where.
IELM 511: Information System design Introduction Part 1. ISD for well structured data – relational and other DBMS Part 2. ISD for systems with non-uniformly.
Chinese Remainder Theorem Dec 29 Picture from ………………………
Algorithms 1.Notion of an algorithm 2.Properties of an algorithm 3.The GCD algorithm 4.Correctness of the GCD algorithm 5.Termination of the GCD algorithm.
MA/CSSE 473 Day 06 Euclid's Algorithm. MA/CSSE 473 Day 06 Student Questions Odd Pie Fight Euclid's algorithm (if there is time) extended Euclid's algorithm.
Math 3121 Abstract Algebra I Lecture 5 Finish Sections 6 + Review: Cyclic Groups, Review.
MA/CSSE 473 Day 08 Extended Euclid's Algorithm Modular Division Fermat's little theorem.
Tuesday’s lecture: Today’s lecture: One-way permutations (OWPs)
Application: Algorithms Lecture 20 Section 3.8 Wed, Feb 21, 2007.
Ref: Pfleeger96, Ch.31 Properties of Arithmetic Reference: Pfleeger, Charles P., Security in Computing, 2nd Edition, Prentice Hall, 1996.
AF2. Turn off your phones Primes, gcd, some examples, reading.
Application: Algorithms Lecture 19 Section 3.8 Tue, Feb 20, 2007.
Cryptography Lecture 14 Arpita Patra © Arpita Patra.
AF2. Turn off your phones Primes, gcd, some examples, reading.
MA/CSSE 473 Day 09 Modular Division Revisited Fermat's Little Theorem Primality Testing.
Chapter 4 With Question/Answer Animations 1. Chapter Summary Divisibility and Modular Arithmetic - Sec 4.1 – Lecture 16 Integer Representations and Algorithms.
Ch04-Number Theory and Cryptography 1. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic.
CS480 Cryptography and Information Security Huiping Guo Department of Computer Science California State University, Los Angeles 3. Mathematics of Cryptography.
Number Theory Lecture 1 Text book: Discrete Mathematics and its Applications, 7 th Edition.
Great Theoretical Ideas in Computer Science.
MA/CSSE 473 Day 07 Extended Euclid's Algorithm Modular Division Fermat's little theorem intro.
Fuw-Yi Yang1 Textbook: Introduction to Cryptography 2nd ed. By J.A. Buchmann Chap 1 Integers Department of Computer Science and Information Engineering,
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Number Theory. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic principles of divisibility,
MA/CSSE 473 Day 07 Extended Euclid's Algorithm Modular Division
Discrete Math II Howon Kim
MA/CSSE 473 Day 06 Euclid's Algorithm.
MA/CSSE 473 Day 06 Euclid's Algorithm.
Advanced Algorithms Analysis and Design
Numerical Algorithms x x-1 Numerical Algorithms
Number Theory and Modular Arithmetic
Numerical Algorithms x x-1
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett
Number Theory (Chapter 7)
Prime and Relatively Prime Numbers
Discrete Math for CS CMPSC 360 LECTURE 12 Last time: Stable matching
Copyright © Zeph Grunschlag,
Application: Algorithms
Application: Algorithms
Presentation transcript:

COMP 170 L2 Page 1 L05: Inverses and GCDs l Objective: n When does have an inverse? n How to compute the inverse? n Need: Greatest common dividers (GCDs) n Results will be used in L06.

COMP 170 L2 Page 2 Inverses and GCDs l Greatest Common Divisors (GCDs) n Definitions n Euclid’s Division Theorem n The GCD Algorithm l Multiplicative Inverses n Definition and Properties n Link to GCD n The extended GCD algorithm. n Computing inverses

COMP 170 L2 Page 3 Divisors of an Integer

COMP 170 L2 Page 4 Prime Numbers

COMP 170 L2 Page 5 Common Divisors

COMP 170 L2 Page 6 Relatively Prime

COMP 170 L2 Page 7 How to Find GCD? l How to calculate gcd(m, n)? n Need Euclid’s division theorem

COMP 170 L2 Page 8 Inverses and GCDs l Greatest Common Divisors (GCDs) n Definitions n Euclid’s Division Theorem n The GCD Algorithm l Multiplicative Inverses n Definition and Properties n Link to GCD n The extended GCD algorithm. n Computing inverses

COMP 170 L2 Page 9 Euclid’s Division Theorem

COMP 170 L2 Page 10 Euclid’s Division Theorem

COMP 170 L2 Page 11

COMP 170 L2 Page 12

COMP 170 L2 Page 13

COMP 170 L2 Page 14 Proof by Smallest Counter Example

COMP 170 L2 Page 15

COMP 170 L2 Page 16 Inverses and GCDs l Greatest Common Divisors (GCDs) n Definitions n Euclid’s Division Theorem n The GCD Algorithm l Multiplicative Inverses n Definition and Properties n Link to GCD n The extended GCD algorithm. n Computing inverses.

COMP 170 L2 Page 17 A Lemma l This lemma gives us a way to calculate GCDs. l Example n 10 = 4 * n gcd(10, 4) = 2 = gcd(4, 2)

COMP 170 L2 Page 18

COMP 170 L2 Page 19

COMP 170 L2 Page 20 Euclid’s GCD algorithm l The 2 nd argument is nonnegative l Decreases in each recursive call l Becomes 0 in a finite number of steps

COMP 170 L2 Page 21 Euclid’s GCD algorithm

COMP 170 L2 Page 22 Euclid’s GCD algorithm

COMP 170 L2 Page 23 Inverses and GCDs l Greatest Common Divisors (GCDs) n Definitions n Euclid’s Division Theorem n The GCD Algorithm l Multiplicative Inverses n Definition and Properties n Link to GCD n The extended GCD algorithm. n Computing inverses

COMP 170 L2 Page 24 Multiplicative Inverse mod n

COMP 170 L2 Page 25 Determine Inverses from Multiplication Table l Which nonzero elements of have multiplicative inverses?

COMP 170 L2 Page 26 Determine Inverses from Multiplication Table l Which nonzero elements of have multiplicative inverses?

COMP 170 L2 Page 27 l It seems determining inverses is simple n Just scan multiplication tables l But do you see a problem with this method? n Yes, too complex… n For e-commerce, we need to determine inverse of integers of more 200 or 300 digits… n Computationally. l Next: n Show a way to prove inverse does not exist. n Develop efficient way to calculate inverses if they exist. Determine Inverses from Multiplication Table

COMP 170 L2 Page 28 Multiplicative Inverse mod n

COMP 170 L2 Page 29 Multiplicative Inverse mod n

COMP 170 L2 Page 30 Proving Inverse does not Exist l Gives us a way to prove that inverse does not exist

COMP 170 L2 Page 31 Proving Inverse does not Exist

COMP 170 L2 Page 32 Proving Inverse does not Exist

COMP 170 L2 Page 33 Proving Inverse does not Exist

COMP 170 L2 Page 34 Inverses and GCDs l Greatest Common Divisors (GCDs) n Definitions n Euclid’s Division Theorem n The GCD Algorithm l Multiplicative Inverses n Definition and Properties n Link to GCD n The extended GCD algorithm. n Computing inverses

COMP 170 L2 Page 35 Link to GCD l Objective: n Show the following two important results

COMP 170 L2 Page 36 Modular Equations and Normal Equations

COMP 170 L2 Page 37

COMP 170 L2 Page 38 Inverse and Normal Equations

COMP 170 L2 Page 39 Clue on Finding Inverse l Second part of the proof of Lemma 2.8: l Does this give us a way to find the inverse of a? n Yes,

COMP 170 L2 Page 40 Clue on Finding Inverse l So, given a and n, if we can find x and y, such that a x + ny =1 (*) Then, we find inverse of a, i.e., x mod n l Given a and n, how do we find x and y, to satisfy (*)? n Link to GCD

COMP 170 L2 Page 41 Link to GCD

COMP 170 L2 Page 42 Link to GCD/Summary

COMP 170 L2 Page 43 Inverses and GCDs l Greatest Common Divisors (GCDs) n Definitions n Euclid’s Division Theorem n The GCD Algorithm l Multiplicative Inverses n Definition and Properties n Link to GCD n The extended GCD algorithm. n Computing inverses

COMP 170 L2 Page 44 The GCD algorithm Revisited l Computes GCD, but does not give x and y such that a x + ny =1

COMP 170 L2 Page 45

COMP 170 L2 Page 46 The Extended GCD Algorithm/Base Case l Base case: k=jq gcd(k, j) = j j * 1 + k * 0 = gcd(k, j), x=1, y=0

COMP 170 L2 Page 47 The Extended GCD Algorithm/Induction l Induction: k \= jq

COMP 170 L2 Page 48

COMP 170 L2 Page 49 The Extended GCD Algorithm

COMP 170 L2 Page 50 The Extended GCD Algorithm/Example

COMP 170 L2 Easy Manual Way to Find x and y l Without remembering: Page 51

COMP 170 L2 The Extended GCD Algorithm Page 52 l Proved by induction already.

COMP 170 L2 Related Results l Together, those two imply: Page 53

COMP 170 L2 Related Results Page 54 l Together, those two imply:

COMP 170 L2

Page 56 Inverses and GCDs l Greatest Common Divisors (GCDs) n Definitions n Euclid’s Division Theorem n The GCD Algorithm l Multiplicative Inverses n Definition and Properties n Link to GCD n The extended GCD algorithm. n Computing inverses

COMP 170 L2 Extend GCD Algo and Inverses Page 57 l Together, those two imply:

COMP 170 L2 Finding Inverse/Example l Find the Page 58

COMP 170 L2 Manual Way to Find Inverse Page 59

COMP 170 L2

: Recap l Proved: Page 61 l Proof technique l Proof by contradiction l Proof by smallest counter example

COMP 170 L : Recap Page 62

COMP 170 L : Today l Greatest Common Divisors (GCDs) n Definitions n Euclid’s Division Theorem n The GCD Algorithm l Multiplicative Inverses n Definition and Properties n Link to GCD (only results, proofs later) n The extended GCD algorithm. n Computing inverses Page 63

COMP 170 L : Recap Page 64 l a has multiplicative inverse in Zn iff gcd(a, n) =1 l In that case, inverse of a = x mod n. l Today : prove correctness

COMP 170 L2 A Note on an Old Exam Question Page 65 l Question: Should I first try to run extended GCD or try to show equation with no solution? How to figure “3” in second case?

COMP 170 L2 A Note on an Old Exam Question l Answer: Factorize the numbers into product of primes Page 66 l 53 cannot be divided by 2, 3, 5, 7, 11, 13, 17, 23, 29 l So, it is a prime number. l Inverse exist. Run extended GCD.

COMP 170 L2 A Note on an Old Exam Question Page 67 l Answer: Factorize the numbers into product of primes l 12 = 3 * 4 l 147 = 3 * 49 l = 3 * 7 * 7 l 12 and 147 have common divisor 3 l Left divisible by 3, but not right. l Write proof