MA/CSSE 473 Day 07 Extended Euclid's Algorithm Modular Division Fermat's little theorem intro.

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

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.
Primality Testing Patrick Lee 12 July 2003 (updated on 13 July 2003)
Sets, Combinatorics, Probability, and Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides.
22C:19 Discrete Structures Integers and Modular Arithmetic
CSE 311 Foundations of Computing I Lecture 13 Number Theory Autumn 2012 CSE
22C:19 Discrete Math Integers and Modular Arithmetic Fall 2010 Sukumar Ghosh.
CSC2110 Discrete Mathematics Tutorial 5 GCD and Modular Arithmetic
Announcements: Homework 1 returned. Comments from Kevin? Homework 1 returned. Comments from Kevin? Matlab: tutorial available at
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2002 Tuesday, 26 November Number-Theoretic Algorithms Chapter 31.
6/20/2015 5:05 AMNumerical Algorithms1 x x1x
Inverses and GCDs Supplementary Notes Prepared by Raymond Wong
Lecture 3.2: Public Key Cryptography II CS 436/636/736 Spring 2012 Nitesh Saxena.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 7 Tuesday, 11/6/01 Number-Theoretic Algorithms Chapter.
Dan Boneh Intro. Number Theory Modular e’th roots Online Cryptography Course Dan Boneh.
CSE 311 Foundations of Computing I Lecture 12 Primes, GCD, Modular Inverse Spring
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
The Polynomial Time Algorithm for Testing Primality George T. Gilbert.
Modular Arithmetic.
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.
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.
Chinese Remainder Theorem Dec 29 Picture from ………………………
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.
Lecture 6.1: Misc. Topics: Number Theory CS 250, Discrete Structures, Fall 2011 Nitesh Saxena.
Network and Computer Security (CS 475) Modular Arithmetic
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.
Tuesday’s lecture: Today’s lecture: One-way permutations (OWPs)
Ch1 - Algorithms with numbers Basic arithmetic Basic arithmetic Addition Addition Multiplication Multiplication Division Division Modular arithmetic Modular.
Ref: Pfleeger96, Ch.31 Properties of Arithmetic Reference: Pfleeger, Charles P., Security in Computing, 2nd Edition, Prentice Hall, 1996.
Discrete Mathematics 4. NUMBER THEORY Lecture 7 Dr.-Ing. Erwin Sitompul
Lecture 3.1: Public Key Cryptography I CS 436/636/736 Spring 2015 Nitesh Saxena.
CSE 311: Foundations of Computing Fall 2013 Lecture 12: Primes, GCD, modular inverse.
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.
Cryptography Lecture 14 Arpita Patra © Arpita Patra.
MA/CSSE 473 Day 07 Euclid's Algorithm. MA/CSSE 473 Day 07 Student Questions Review topics not covered in class Euclid's algorithm (if there is time) extended.
Chapter 1 Algorithms with Numbers. Bases and Logs How many digits does it take to represent the number N >= 0 in base 2? With k digits the largest number.
MA/CSSE 473 Day 09 Modular Division Revisited Fermat's Little Theorem Primality Testing.
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
B504/I538: Introduction to Cryptography
MA/CSSE 473 Day 06 Euclid's Algorithm.
MA/CSSE 473 Day 06 Euclid's Algorithm.
Advanced Algorithms Analysis and Design
Lecture 3.2: Public Key Cryptography II
MA/CSSE 473 Day 08 Randomized Primality Testing Carmichael Numbers
CSE 311 Foundations of Computing I
MATH301- DISCRETE MATHEMATICS Copyright © Nahid Sultana Dr. Nahid Sultana Chapter 4: Number Theory and Cryptography.
Numerical Algorithms x x-1
Number Theory (Chapter 7)
Modular Arithmetic II Lecture 10: Oct 6.
Prime and Relatively Prime Numbers
刘振 上海交通大学 计算机科学与工程系 电信群楼3-509
Applied Symbolic Computation (CS 300) Modular Arithmetic
CSE 311: Foundations of Computing
Applied Symbolic Computation (CS 300) Modular Arithmetic
Lecture 3.1: Public Key Cryptography I
CSE 321 Discrete Structures
Copyright © Zeph Grunschlag,
Applied Symbolic Computation (CS 300) Modular Arithmetic
Applied Symbolic Computation (CS 300) Modular Arithmetic
Modular Inverses Recall the simple encryption function
Mathematical Background for Cryptography
Applied Symbolic Computation (CS 300) Modular Arithmetic
Clements MAΘ October 30th, 2014
From the last time: gcd(a, b) can be characterized in two different ways: It is the least positive value of ax + by where x and y range over integers.
Presentation transcript:

MA/CSSE 473 Day 07 Extended Euclid's Algorithm Modular Division Fermat's little theorem intro

MA/CSSE 473 Day 07 Student Questions Be sure to read today’s announcements, especially the last item. Extended Euclid Algorithm, the “calculate forward, substitute backward” approach Modular Division Fermat's Little Theorem Intro to primality testing.

Recap: Euclid's Algorithm for gcd Another place to read about modular arithmetic, including exponentiation and inverse: Weiss Sections

recap: gcd and linear combinations Lemma: If d divides both a and b, and d = ax + by for some integers x and y, then d = gcd(a,b) Proof – we did it yesterday

recap: Extended Euclid Algorithm Proof that it works –I decided that it is a bit advanced for students who just saw Modular Arithmetic for the first time yesterday. –If you are interested, look up “extended Euclid proof” –We’ll do a convincing example.

Recap: Forward-backward Example: gcd (33, 14) 33 = 2* = 2 * = 1 * = 4 * 1 + 0, so gcd(33, 14) = 1. Now work backwards 1 = Substitute 4 = *5. 1 = 5 – (14 - 2*5) = 3* Substitute 5 = *14 1 = 3(33 - 2*14) -14 = 3 * 33 – 7 * 14 Thus x = 3 and y = -7 Done! A good place to stop and check!

Calculate Modular Inverse (if it exists) Assume that gcd(a, N) = 1. The extended Euclid's algorithm gives us integers x and y such that ax + Ny = 1 This implies ax  1 (mod N), so x is the inverse of a Example: Find mod 33 –We saw before that 3*33 - 7*14 = 1 –-7  26 (mod 33) –So ≡ 26 (mod 33) Recall that Euclid's algorithm is Ѳ(k 3 ), where k is the number of bits of N. Check: 14*26 = 364 = 11*

Modular division We can only divide b by a (modulo N) if N and a are relatively prime In that case b/a = b∙a -1 What is the running time for modular division?

Primality Testing The numbers 7, 17, 19, 71, and 79 are primes, but what about (a typical social security number)? There are some tricks that might help. For example: –If n is even and not equal to 2, it's not prime –n is divisible by 3 iff the sum of its decimal digits is divisible by 3, –n is divisible by 5 iff it ends in 5 or 0 –n is divisible by 7 iff  n/10  - 2*n%10 is divisible by 7 –n is divisible by 11 iff (sum of n's odd digits) – (sum of n's even digits) is divisible by 11. –when checking for factors, we only need to consider prime numbers as candidates –When checking for factors, we only need to look for numbers up to sqrt(n)

Primality testing But this approach is not very fast. Factoring is harder than primality testing. Is there a way to tell whether a number is prime without actually factoring the number? Like a few other things that we have done so far ion this course, this discussion follows Dasgupta, et. al., Algortihms (McGraw-Hill 2008)

Fermat's Little Theorem (1640 AD) Formulation 1: If p is prime, then for every number a with 1 ≤ a <p, a p-1  1 (mod p) Formulation 2: If p is prime, then for every number a with 1 ≤ a <p, a p  a (mod p) These are clearly equivalent. –How do we get from each to the other? We will examine a combinatorial proof of the first formulation.

Fermat's Little Theorem: Proof (part 1) Formulation 1: If p is prime, then for every number a with 1 ≤ a < p, a p-1  1 (mod p) Let S = {1, 2, …, p-1} Lemma –For any nonzero integer a, multiplying all of the numbers in S by a (mod p) permutes S –I.e. {a ∙ n (mod p) : n  S} = S Example: p=7, a=3. Proof of the lemma –Suppose that a∙i  a∙j (mod p). –Since p is prime and a  0, a has an inverse. –Multiplying both sides by a -1 yields i  j (mod p). –Thus, multiplying the elements of S by a (mod p) takes each element to a different element of S. –Thus (by the pigeonhole principle), every number 1..p-1 is a∙i (mod p) for some i in S. i *i362514

Fermat's Little Theorem: Proof (part 2) Formulation 1: If p is prime, then for every number a with 1 ≤ a <p, a p-1  1 (mod p) Let S = {1, 2, …, p-1} Recap of the Lemma: Multiplying all of the numbers in S by a (mod p) permutes S Therefore: {1, 2, …, p-1} = {a∙1 (mod p), a∙2 (mod p), … a∙(p-1) (mod p)} Take the product of all of the elements on each side. (p-1)!  a p-1 (p-1)! (mod p) Since p is prime, (p-1)! is relatively prime to p, so we can divide both sides by it to get the desired result: a p-1  1 (mod p)

Recap: Fermat's Little Theorem Formulation 1: If p is prime, then for every number a with 1 ≤ a <p, a p-1  1 (mod p) Formulation 2: If p is prime, then for every number a with 1 ≤ a <p, a p  a (mod p) Memorize this one. Know how to prove it.