Announcements: Homework 1 returned. Comments from Kevin? Homework 1 returned. Comments from Kevin? Matlab: tutorial available at

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

Sets, Combinatorics, Probability, and Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides.
Chapter Primes and Greatest Common Divisors ‒Primes ‒Greatest common divisors and least common multiples 1.
Announcements: Programming exam next Thursday on breaking codes from chapter 2 Programming exam next Thursday on breaking codes from chapter 2 Written.
Announcements: Subscribe to Angel forums Subscribe to Angel forumsQuestions? Roll Call Today: affine ciphers DTTF/NB479: DszquphsbqizDay 2.
Announcements: Please use pencil on quizzes if possible Please use pencil on quizzes if possible Knuth quotes, part 1 Knuth quotes, part 1Questions?Today:
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
Discrete Structures Chapter 2 Part B Mathematical Induction
Announcements: HW3 updated. Due next Thursday HW3 updated. Due next Thursday Written quiz tomorrow on chapters 1-2 (next slide) Written quiz tomorrow on.
Lecture 4 Discrete Mathematics Harper Langston. Algorithms Algorithm is step-by-step method for performing some action Cost of statements execution –Simple.
DTTF/NB479: Dszquphsbqiz Day 9 Announcements: Homework 2 due now Homework 2 due now Computer quiz Thursday on chapter 2 Computer quiz Thursday on chapter.
Announcements: Homework 2 due now Homework 2 due now Quiz this Friday on concepts from chapter 2 Quiz this Friday on concepts from chapter 2 Practical.
Properties of the Integers: Mathematical Induction
CSE 311 Foundations of Computing I Lecture 12 Primes, GCD, Modular Inverse Spring
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
CS555Spring 2012/Topic 61 Cryptography CS 555 Topic 6: Number Theory Basics.
BY MISS FARAH ADIBAH ADNAN IMK
Chapter 2 The Fundamentals: Algorithms, the Integers, and Matrices
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.
3.4/3.5 The Integers and Division/ Primes and Greatest Common Divisors Let each of a and b be integers. We say that a divides b, in symbols a | b, provided.
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
Prelude to Public-Key Cryptography Rocky K. C. Chang, February
CSE 311 Foundations of Computing I Lecture 15 Recursive Definitions and Structural Induction Autumn 2011 CSE 3111.
Cryptography Inverses and GCD Piotr Faliszewski. GCD(a,b) gcd(a, 0) = a gcd(a, b) = gcd(b, a mod b) a = b*q + r Here: q =  a / b  r = a mod b (a –
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.
Copyright © Zeph Grunschlag, Basic Number Theory Zeph Grunschlag.
Chinese Remainder Theorem Dec 29 Picture from ………………………
CSE 311: Foundations of Computing Fall 2014 Lecture 12: Primes, GCD.
Network and Computer Security (CS 475) Modular Arithmetic
MA/CSSE 473 Day 08 Extended Euclid's Algorithm Modular Division Fermat's little theorem.
CSE 311 Foundations of Computing I Lecture 14 Euclid’s Algorithm Mathematical Induction Autumn 2012 CSE
Tuesday’s lecture: Today’s lecture: One-way permutations (OWPs)
Computing k th Roots Quickly (4/4) Via the Fast Exp algorithm, we know we can quickly compute large powers of large numbers modulo large numbers. What.
Application: Algorithms Lecture 20 Section 3.8 Wed, Feb 21, 2007.
Properties of the gcd Theorem: For any two integers a,b there exist integers x,y such that xa + yb = gcd(a,b). A proof will not be given at this point.
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.
Application: Algorithms Lecture 19 Section 3.8 Tue, Feb 20, 2007.
Cryptography Lecture 14 Arpita Patra © Arpita Patra.
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.
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,
Agenda Review:  Relation Properties Lecture Content:  Divisor and Prime Number  Binary, Octal, Hexadecimal Review & Exercise.
Number Theory. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic principles of divisibility,
Number-Theoretic Algorithms
CMPS 2433 – Coding Theory Chapter 3
MA/CSSE 473 Day 07 Extended Euclid's Algorithm Modular Division
Advanced Algorithms Analysis and Design
CSE 311 Foundations of Computing I
MATH301- DISCRETE MATHEMATICS Copyright © Nahid Sultana Dr. Nahid Sultana Chapter 4: Number Theory and Cryptography.
Applied Discrete Mathematics Week 4: Number Theory
Number Theory (Chapter 7)
Week #5 – 23/25/27 September 2002 Prof. Marie desJardins
Applied Symbolic Computation (CS 300) Modular Arithmetic
Applied Symbolic Computation (CS 300) Modular Arithmetic
The Division Algorithm
Copyright © Zeph Grunschlag,
Application: Algorithms
Applied Symbolic Computation (CS 300) Modular Arithmetic
Applied Symbolic Computation (CS 300) Modular Arithmetic
Applied Discrete Mathematics Week 10: Introduction to Counting
Applied Symbolic Computation (CS 300) Modular Arithmetic
Discrete Mathematics Chapter 4 Number Theory. Discrete Mathematics Chapter 4 Number Theory.
Sets, Combinatorics, Probability, and Number Theory
Presentation transcript:

Announcements: Homework 1 returned. Comments from Kevin? Homework 1 returned. Comments from Kevin? Matlab: tutorial available at Matlab: tutorial available at Homework 2 due Tuesday Homework 2 due Tuesday Quiz this Friday on concepts from chapter 2 (tentative) Quiz this Friday on concepts from chapter 2 (tentative) Practical quiz next week on breaking codes from chapter 2 Practical quiz next week on breaking codes from chapter 2Questions?Today: Euclid’s algorithm Euclid’s algorithm Congruences if time Congruences if time DTTF/NB479: DszquphsbqizDay 9

Basics 1: Divisibility Definition: Property 1: Property 2 (transitive): Property 3 (linear combinations):

Basics 2: Primes Any integer p > 1 divisible by only p and 1. How many are there? Prime number theorem: Let  (x) be the number of primes less than x. Let  (x) be the number of primes less than x. Then Then Application: how many 319-digit primes are there? Application: how many 319-digit primes are there? Every positive integer is a unique product of primes. Every positive integer is a unique product of primes.

Basics: 3. GCD gcd(a,b)=max j (j|a and j|b). Def.: a and b are relatively prime iff gcd(a,b)=1 gcd(14,21) easy… What about gcd(1856, 5862)? gcd( , )? Do you really want to factor each one? What’s our alternative?

Euclid’s Algorithm gcd(a,b) { if (a < b) swap (a,b) // a > b r = a % b while (r ~= 0) { a = b b = r r = a % b } gcd = b // last r ~= 0 } Calculate gcd(1856, 5862) =2

Euclid’s Algorithm gcd(a,b) { if (a > b) swap (a,b) // a > b r = a % b while (r ~= 0) { a = b b = r r = a % b } gcd = b // last r ~= 0 } Assume a > b Let q i and r i be the series of quotients and remainders, respectively, found along the way. a = q 1 b + r 1 b = q 2 r 1 + r 2 r 1 = q 3 r 2 + r 3... r i-2 = q i r i-1 + r i r k-2 = q k r k-1 + r k r k-1 = q k+1 r k You’ll prove this computes the gcd in Homework 3 (by induction)… r k is gcd(a,b)

Fundamental result: If d = gcd(a,b) then ax + by = d For some integers x and y. These ints are just a by-product of the Euclidean algorithm! Allows us to find a -1 (mod n) very quickly… Choose b = n and d = 1. Choose b = n and d = 1. If gcd(a,n) =1, then ax + ny = 1 If gcd(a,n) =1, then ax + ny = 1 ax = 1 (mod n) because it differs from 1 by a multiple of n ax = 1 (mod n) because it differs from 1 by a multiple of n Therefore, x = a -1 (mod n). Therefore, x = a -1 (mod n). Why does this work? How do we find x and y?

Why does this work? Given a,b ints, not both 0, and gcd(a,b) = d. Prove ax + by = d Recall gcd(a,b,)=d = r k is the last non-zero remainder found via Euclid. We’ll show the property true for all remainders r j (by strong induction) Assume a > b Let q i and r i be the series of quotients and remainders, respectively, found along the way. a = q 1 b + r 1 b = q 2 r 1 + r 2 r 1 = q 3 r 2 + r 3... r i-2 = q i r i-1 + r i r k-2 = q k r k-1 + r k r k-1 = q k+1 r k

How to find x and y? To find x, take x 0 = 1, x 1 = 0, x j = x j-2 – q j-1 x j-1 To find y, take y 0 = 0, y 1 = 1, y j = y j-2 – q j-1 y j-1 Use to calculate x k and y k (the desired result) Example:gcd(5862,1856)=2 Yields x = -101, y = 319 Assume a > b Let q i and r i be the series of quotients and remainders, respectively, found along the way. a = q 1 b + r 1 b = q 2 r 1 + r 2 r 1 = q 3 r 2 + r 3... r i-2 = q i r i-1 + r i r k-2 = q k r k-1 + r k r k-1 = q k+1 r k x and y swapped from book, which assumes that a < b on p. 69 Check: 5862(-101) (319) = 2?