CSE 311 Foundations of Computing I Lecture 12 Primes, GCD, Modular Inverse Spring 2013 1.

Slides:



Advertisements
Similar presentations
CS 202 Epp section ?? Aaron Bloomfield
Advertisements

Section 4.1: Primes, Factorization, and the Euclidean Algorithm Practice HW (not to hand in) From Barr Text p. 160 # 6, 7, 8, 11, 12, 13.
Sets, Combinatorics, Probability, and Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides.
1 Section 2.4 The Integers and Division. 2 Number Theory Branch of mathematics that includes (among other things): –divisibility –greatest common divisor.
CSE 311 Foundations of Computing I Lecture 13 Number Theory Autumn 2012 CSE
Chapter Primes and Greatest Common Divisors ‒Primes ‒Greatest common divisors and least common multiples 1.
The Fundamental Theorem of Arithmetic (2/12) Definition (which we all already know). A number greater than 1 is called prime if its only divisors are 1.
22C:19 Discrete Math Integers and Modular Arithmetic Fall 2010 Sukumar Ghosh.
Notation Intro. Number Theory Online Cryptography Course Dan Boneh
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.
6/20/2015 5:05 AMNumerical Algorithms1 x x1x
Chapter 4 – Finite Fields Introduction  will now introduce finite fields  of increasing importance in cryptography AES, Elliptic Curve, IDEA, Public.
CSE 321 Discrete Structures Winter 2008 Lecture 8 Number Theory: Modular Arithmetic.
Fundamental Theorem of Arithmetic. Euclid's Lemma If p is a prime that divides ab, then p divides a or p divides b.
1 Integers and Division CS/APMA 202 Rosen section 2.4 Aaron Bloomfield.
CSE 321 Discrete Structures Winter 2008 Lecture 10 Number Theory: Primality.
CS555Spring 2012/Topic 61 Cryptography CS 555 Topic 6: Number Theory Basics.
Integers Number Theory = Properties of Integers
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 3 (Part 2): The Fundamentals: Algorithms, the.
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.
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)
Module :MA3036NI Cryptography and Number Theory Lecture Week 7
CPSC 3730 Cryptography and Network Security
CS 312: Algorithm Analysis Lecture #4: Primality Testing, GCD This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative.
CompSci 102 Discrete Math for Computer Science
CS 312: Algorithm Analysis Lecture #4: Primality Testing, GCD This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative.
Section 2.2: Affine Ciphers; More Modular Arithmetic Shift ciphers use an additive key. To increase security, we can add a multiplicative parameter. –For.
Chapter 2 (Part 1): The Fundamentals: Algorithms, the Integers & Matrices The Integers and Division (Section 2.4)
CSE 311: Foundations of Computing Fall 2014 Lecture 12: Primes, GCD.
Information Security Lab. Dept. of Computer Engineering 87/121 PART I Symmetric Ciphers CHAPTER 4 Finite Fields 4.1 Groups, Rings, and Fields 4.2 Modular.
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.
CS Modular Division and RSA1 RSA Public Key Encryption To do RSA we need fast Modular Exponentiation and Primality generation which we have shown.
MA/CSSE 473 Day 08 Extended Euclid's Algorithm Modular Division Fermat's little theorem.
Notation Intro. Number Theory Online Cryptography Course Dan Boneh
CSE 311 Foundations of Computing I Lecture 14 Euclid’s Algorithm Mathematical Induction Autumn 2012 CSE
Ch1 - Algorithms with numbers Basic arithmetic Basic arithmetic Addition Addition Multiplication Multiplication Division Division Modular arithmetic Modular.
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.
CSE 311: Foundations of Computing Fall 2013 Lecture 12: Primes, GCD, modular inverse.
CSE 311: Foundations of Computing Fall 2013 Lecture 11: Modular arithmetic and applications.
CS 312: Algorithm Analysis Lecture #4: Primality Testing, GCD This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative.
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 2 The Fundamentals: Algorithms,
Chapter 4 With Question/Answer Animations 1. Chapter Summary Divisibility and Modular Arithmetic - Sec 4.1 – Lecture 16 Integer Representations and Algorithms.
Number Theory Lecture 1 Text book: Discrete Mathematics and its Applications, 7 th Edition.
CSE 311 Foundations of Computing I Lecture 12 Modular Arithmetic and Applications Autumn 2012 CSE
CSE 311 Foundations of Computing I Lecture 11 Modular Exponentiation and Primes Autumn 2011 CSE 3111.
MA/CSSE 473 Day 07 Extended Euclid's Algorithm Modular Division Fermat's little theorem intro.
Number-Theoretic Algorithms
CS 210 Discrete Mathematics The Integers and Division (Section 3.4)
Divisibility and Primes
Numerical Algorithms x x-1 Numerical Algorithms
CSE 311 Foundations of Computing I
CSE 311 Foundations of Computing I
Greatest Common Divisor
CSE 311 Foundations of Computing I
MATH301- DISCRETE MATHEMATICS Copyright © Nahid Sultana Dr. Nahid Sultana Chapter 4: Number Theory and Cryptography.
Number Theory and Modular Arithmetic
Numerical Algorithms x x-1
Number Theory (Chapter 7)
Topic 6: Number Theory Basics
Discrete Math for CS CMPSC 360 LECTURE 12 Last time: Stable matching
CSE 311 Foundations of Computing I
CSE 311: Foundations of Computing
CSE 321 Discrete Structures
CSE 321 Discrete Structures
Copyright © Zeph Grunschlag,
Divisibility and Modular Arithmetic
Useful GCD Fact If a and b are positive integers, then gcd(a,b) = gcd(b, a mod b) Proof: By definition of mod, a = qb+ (a mod b) for.
Sets, Combinatorics, Probability, and Number Theory
Presentation transcript:

CSE 311 Foundations of Computing I Lecture 12 Primes, GCD, Modular Inverse Spring

Announcements Reading assignments – Today : 7 th Edition: (the rest of the chapter is interesting!) 6 th Edition: 3.5, 3.6 – Monday: Mathematical Induction 7 th Edition: 5.1, th Edition: 4.1, 4.2 2

Fast modular exponentiation 3

Fast exponentiation algorithm What if the exponent is not a power of two? = The fast exponentiation algorithm computes a n mod m in time O(log n) = …

Primality An integer p greater than 1 is called prime if the only positive factors of p are 1 and p. A positive integer that is greater than 1 and is not prime is called composite. 5

Fundamental Theorem of Arithmetic 6 Every positive integer greater than 1 has a unique prime factorization 48 = = ,523 = 45, ,950 = ,234,567,890 = ,607 3,803

Factorization 7 If n is composite, it has a factor of size at most sqrt(n)

Euclid’s theorem Proof: By contradiction Suppose there are a finite number of primes: p 1, p 2,..., p n 8 There are an infinite number of primes.

Distribution of Primes If you pick a random number n in the range [x, 2x], what is the chance that n is prime?

Famous Algorithmic Problems Primality Testing: – Given an integer n, determine if n is prime Factoring – Given an integer n, determine the prime factorization of n 10

Factoring Factor the following 232 digit number [RSA768]:

Greatest Common Divisor GCD(a, b): Largest integer d such that d|a and d|b – GCD(100, 125) = – GCD(17, 49) = – GCD(11, 66) = – GCD(13, 0 ) = – GCD(180, 252) = 13

GCD and Factoring 14 a = = 46,200 b = = 204,750 GCD(a, b) = 2 min(3,1) 3 min(1,2) 5 min(2,3) 7 min(1,1) 11 min(1,0) 13 min(0,1) Factoring is expensive! Can we compute GCD(a,b) without factoring?

Useful GCD fact 15 If a and b are positive integers, then gcd(a,b) = gcd(b, a mod b) Proof: By definition a = (a div b) b + (a mod b) If d|a and d|b then d|(a mod b): If d|b and d|(a mod b) then d|a :

Euclid’s Algorithm 16 GCD(660,126) Repeatedly use the GCD fact to reduce numbers until you get GCD(x,0)=x

Euclid’s Algorithm GCD(x, y) = GCD(y, x mod y) 17 int GCD(int a, int b){ /* a >= b, b > 0 */ int tmp; int x = a; int y = b; while (y > 0){ tmp = x % y; x = y; y = tmp; } return x; } Example: GCD(660, 126)

Bézoit’s Theorem 18 If a and b are positive integers, then there exist integers s and t such that gcd(a,b) = sa + tb.

Extended Euclid’s Algorithm Can use Euclid’s Algorithm to find s,t such that sa+tb=gcd(a,b) e.g. gcd(35,27): 35 = = 8 27= = 3 8 = = 2 3 = = 1 2 = = = 3 – 1 ( ) = (-1) =(-1) ( ) = (-10) 8 = 19

Multiplicative Inverse mod m Suppose GCD(a, m) = 1 By Bézoit’s Theorem, there exist integers s and t such that sa + tm = 1. s is the multiplicative inverse of a: 1 = (sa + tm) mod m = sa mod m 20

Solving Modular Equations Solving ax ≡ b (mod m) for unknown x when gcd(a,m)=1. 1.Find s such that sa+tm=1 2.Compute a -1 = s mod m, the multiplicative inverse of a modulo m 3.Set x = (a -1 b) mod m 21

Multiplicative Cipher: f(x) = ax mod m For a multiplicative cipher to be invertible: f(x) = ax mod m : {0, m-1} → {0, m-1} must be one to one and onto 22 Lemma: If there is an integer b such that ab mod m = 1, then the function f(x) = ax mod m is one to one and onto.