CSE 311: Foundations of Computing Fall 2013 Lecture 11: Modular arithmetic and applications.

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.
The Integers and Division. Outline Division: Factors, multiples Exercise 2.3 Primes: The Fundamental Theorem of Arithmetic. The Division Algorithm Greatest.
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.
CSE115/ENGR160 Discrete Mathematics 03/13/12 Ming-Hsuan Yang UC Merced 1.
Number Theory and Cryptography
Notation Intro. Number Theory Online Cryptography Course Dan Boneh
CSE115/ENGR160 Discrete Mathematics 03/15/11
6/20/2015 5:05 AMNumerical Algorithms1 x x1x
CSE 321 Discrete Structures Winter 2008 Lecture 8 Number Theory: Modular Arithmetic.
1 Integers and Division CS/APMA 202 Rosen section 2.4 Aaron Bloomfield.
CSE 321 Discrete Structures Winter 2008 Lecture 10 Number Theory: Primality.
CSE 311 Foundations of Computing I Lecture 12 Primes, GCD, Modular Inverse Spring
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
Divisibility October 8, Divisibility If a and b are integers and a  0, then the statement that a divides b means that there is an integer c such.
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.
CSE 504 Discrete Mathematics & Foundations of Computer Science
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.
MATH 224 – Discrete Mathematics
Discrete Mathematics CS 2610 March 17, Number Theory Elementary number theory, concerned with numbers, usually integers and their properties or.
Prep Math Competition, Lec. 1Peter Burkhardt1 Number Theory Lecture 1 Divisibility and Modular Arithmetic (Congruences)
CompSci 102 Discrete Math for Computer Science February 16, 2012 Prof. Rodger.
Chapter The Integers and Division Division
Data Security and Encryption (CSE348) 1. Lecture # 12 2.
Foundations of Computing I CSE 311 Fall It’s Boolean algebra again Definition for  based on  Definition for  based on  Complement works like.
Number Theory 이재원 School of Information Technology Sungshin W. University.
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.
22C:19 Discrete Structures Integers and Modular Arithmetic Fall 2014 Sukumar Ghosh.
9/22/15UB Fall 2015 CSE565: S. Upadhyaya Lec 7.1 CSE565: Computer Security Lecture 7 Number Theory Concepts Shambhu Upadhyaya Computer Science & Eng. University.
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)
Module #9 – Number Theory 1/5/ Algorithms, The Integers and Matrices.
Foundations of Computing I CSE 311 Fall Review: Division Theorem Let a be an integer and d a positive integer. Then there are unique integers q.
CSE 311: Foundations of Computing Fall 2013 Lecture 12: Primes, GCD, modular inverse.
Discrete Mathematics
Divisibility and Modular Arithmetic
MA/CSSE 473 Day 09 Modular Division Revisited Fermat's Little Theorem Primality Testing.
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 2 The Fundamentals: Algorithms,
The Fundamentals: Algorithms, Integers, and Matrices CSC-2259 Discrete Structures Konstantin Busch - LSU1.
Ch04-Number Theory and Cryptography 1. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic.
Chapter 4 With Question/Answer Animations 1. Chapter Motivation Number theory is the part of mathematics devoted to the study of the integers and their.
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.
Chapter 3 The Fundamentals: Algorithms, the integers, and matrices Section 3.4: The integers and division Number theory: the part of mathematics involving.
Number Theory. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic principles of divisibility,
CS 210 Discrete Mathematics The Integers and Division (Section 3.4)
CSE15 Discrete Mathematics 03/15/17
Integers and Division Section 3.4.
Numerical Algorithms x x-1 Numerical Algorithms
CSE 311 Foundations of Computing I
MATH301- DISCRETE MATHEMATICS Copyright © Nahid Sultana Dr. Nahid Sultana Chapter 4: Number Theory and Cryptography.
CSE 311 Foundations of Computing I
CSE 311 Foundations of Computing I
CSE 311 Foundations of Computing I
CSE 311: Foundations of Computing
Discrete Math for CS CMPSC 360 LECTURE 12 Last time: Stable matching
CSE 311 Foundations of Computing I
CSE 321 Discrete Structures
CSE 321 Discrete Structures
CMSC 203, Section 0401 Discrete Structures Fall 2004 Matt Gaston
Copyright © Zeph Grunschlag,
Clements MAΘ October 30th, 2014
Number Theory.
Presentation transcript:

CSE 311: Foundations of Computing Fall 2013 Lecture 11: Modular arithmetic and applications

announcements Reading assignment Modular arithmetic , 7 th edition , 6 th edition

review: divisibility Integers a, b, with a ≠ 0, we say that a divides b if there is an integer k such that b = ka. The notation a | b denotes “a divides b.”

review: division theorem Let a be an integer and d a positive integer. Then there are unique integers q and r, with 0 ≤ r < d, such that a = dq + r. q = a div d r = a mod d

review: modular arithmetic Let a and b be integers, and m be a positive integer. We say a is congruent to b modulo m if m divides a – b. We use the notation a ≡ b (mod m) to indicate that a is congruent to b modulo m.

review: modular arithmetic Let a and b be integers, and let m be a positive integer. Then a ≡ b (mod m) if and only if a mod m = b mod m.

review: modular arithmetic Let m be a positive integer. If a ≡ b (mod m) and c ≡ d (mod m), then a + c ≡ b + d (mod m) and ac ≡ bd (mod m)

example Let n be an integer. Prove that n 2 ≡ 0 (mod 4) or n 2 ≡ 1 (mod 4)

n-bit unsigned integer representation

signed integer representation

two’s complement representation Key property: Twos complement representation of any number y is equivalent to y mod 2 n so arithmetic works mod 2 n

signed vs two’s complement Signed Two’s complement

two’s complement representation

basic applications of mod Hashing Pseudo random number generation Simple cipher

hashing

pseudo random number generation Linear Congruential method

simple cipher Caesar cipher, A = 1, B = 2,... – HELLO WORLD Shift cipher – f(p) = (p + k) mod 26 – f -1 (p) = (p – k) mod 26 More general – f(p) = (ap + b) mod 26

modular exponentiation mod 7 X aa1a1 a2a2 a3a3 a4a4 a5a5 a6a

exponentiation Compute Compute mod Output is small – need to keep intermediate results small

repeated squaring – small and fast Since a mod m ≡ a (mod m) for any a we have a 2 mod m = (a mod m) 2 mod m and a 4 mod m = (a 2 mod m) 2 mod m and a 8 mod m = (a 4 mod m) 2 mod m and a 16 mod m = (a 8 mod m) 2 mod m and a 32 mod m = (a 16 mod m) 2 mod m Can compute a k mod m for k=2 i in only i steps

fast exponentiation int FastExp(int a, int n, m){ long v = (long) a; int exp = 1; for (int i = 1; i <= n; i++){ v = (v * v) % m; exp = exp + exp; Console.WriteLine("i : " + i + ", exp : " + exp + ", v : " + v ); } return (int)v; }

program trace i : 1, exp : 2, v : i : 2, exp : 4, v : i : 3, exp : 8, v : i : 4, exp : 16, v : i : 5, exp : 32, v : i : 6, exp : 64, v : i : 7, exp : 128, v : i : 8, exp : 256, v : i : 9, exp : 512, v : i : 10, exp : 1024, v : i : 11,exp : 2048, v : 4207 i : 12, exp : 4096, v : i : 13, exp : 8192, v : i : 14, exp : 16384, v : i : 15, exp : 32768, v : i : 16, exp : 65536, v : 29057

fast exponentiation algorithm What if the exponent is not a power of two? = a = a 2 16 · a 2 13 · a 2 12 · a 2 11 · a 2 10 · a 2 9 · a 2 5 · a 2 3 · a 2 2 · a 2 0 a mod m= (a 2 16 mod m · a 2 13 mod m · a 2 12 mod m · a 2 11 mod m · a 2 10 mod m · a 2 9 mod m · a 2 5 mod m · a 2 3 mod m · a 2 2 mod m · a 2 0 mod m) mod m

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.

fundamental theorem of arithmetic Every positive integer greater than 1 has a unique prime factorization 48 = = ,523 = 45, ,950 = ,234,567,890 = ,607 3,803

factorization

euclid’s theorem