Theory of RSA. Hiroshi Toyoizumi 1. December 8,

Size: px
Start display at page:

Download "Theory of RSA. Hiroshi Toyoizumi 1. December 8,"

Transcription

1 Theory of RSA Hiroshi Toyoizumi 1 December 8, toyoizumi@waseda.jp

2 2 Introduction This is brief introduction of number theory related to the so-called RSA cryptography. This handout is based on A Friendly Introduction To Number Theory by Joseph H. Silverman, Prentice Hall College Div 2005.

3 Chapter 1 Basic Number Theory 1.1 Prime Number 1.2 Greatest Common Devisor Example 1.1. Find the greatest common devisor: Use Euclidean algorithm. 1. Divide 132 by 36 and find the remainder. gcd(36, 132). (1.1) 132 = (1.2) 2. Divide 36 by the remainder 24, and then find the remainder. 36 = (1.3) 3. Again, divide the remainder 24 by the remainder 12. Now we find there is no remainder. The previous remainder 12 is gcd(36,132). General Euclidean algorithm: Find gcd(a,b). Put r 1 = a and r 0 = b, then 24 = (1.4) r 1 = q 1 r 0 + r 1 (1.5) r 0 = q 2 r 1 + r 2 (1.6)... (1.7) r n 3 = q n 1 r n 2 + r n 1 (1.8) r n 2 = q n r n 1 + r n (1.9) r n 1 = q n+1 r n. (1.10) (1.11) 3

4 4 CHAPTER 1. BASIC NUMBER THEORY Then, r(n) is gcd(a,b). Exercise 1.1. Find gcd(12345,67890). 1.3 Linear equation and extended GCD Find x and y satisfing ax + by = gcd(a,b), (1.12) where gcd(a,b) is the greatest common devisor of a and b. Example 1.2. Find x and y satisfing 22x + 60y = gcd(22,60). (1.13) By Euclidean algorithm, we have 60 = = = = = 2 2. Thus, gcd(22,60) = 2. We will extend this algorithm. 16 = = a 2b 6 = = b 1 (a 2b) = a + 3b 4 = = (a 2b) 2( a + 3b) = 3a 8b 2 = = ( a + 3b) 1 (3a 8b) = 4a + 11b 4 = 2 2. Thus, we can find 2 = 4a + 11b = = = 2. (1.14) Note that the pair ( 4,11) is not the unique solution!. Exercise 1.2. Find Find x and y satisfing ax + by = gcd(a,b), (1.15) where a = 12453,b = 2347.

5 1.4. RESIDUE CLASS Residue Class Definition 1.1. When a b is divided by m, then we say that a b mod m. (1.16) 3 = 3 mod 7. (1.17) 13 = 6 mod 7. (1.18) Lemma 1.1. If a 1 b 1 mod m and a 2 b 2 mod m, we have a 1 + a 2 b 1 + b 2 mod m. (1.19) a 1 a 2 b 1 b 2 mod m. (1.20)

6 Chapter 2 Theorems 2.1 Fermat s Little Theorem How can you check this? The answer is this mod 101. (2.1) Theorem 2.1 (Fermat s Little Theorem). Let p be a prime number and a be an integer with Then, a 0 mod p. (2.2) a p 1 1 mod p. (2.3) Example 2.1. What is 2 35 mod 7? Remember 2 6 = 1 mod 7 by Fermat s Little Theorem. Then, 2 35 = mod 7 = (2 6 ) mod 7 = mod 7 = 32 = 4 mod 7. Lemma 2.1. Let p be a prime number and a be an integer with Then, a 0 mod p. (2.4) {a,2a,3a,...,(p 1)a mod p} = {1,2,3,..., p 1 mod p}. (2.5) 6

7 2.2. EULER S FORMULA 7 Proof. It is enough to show a, 2a, 3a,...,(p 1)a mod p are different each other. We will show it by induction. Assume for some 1 j,k p 1. Then, ja ka mod p, (2.6) ( j k)a 0 mod p. (2.7) Since a 0 mod p, j k = 0 mod p. Since j k < p, j k = 0. Proof of Fermat s Little Theorem. By Lemma 2.1, {a,2a,3a,...,(p 1)a mod p} = {1,2,3,..., p 1 mod p}. (2.8) Thus, the product of all elements is equal, and Or, a 2a 3a (p 1)a (p 1) mod p. (2.9) Since (p 1)! 0 mod p, we have a p 1 (p 1)! (p 1)! mod p. (2.10) a p 1 1 mod p. (2.11) Exercise mod 73. (2.12) Exercise 2.2. Find x which satisfies x 86 6 mod 29. (2.13) 2.2 Euler s Formula Definition 2.1. ϕ(m) = #{a : 1 a m,gcd(a,m) = 1}. (2.14) The function ϕ(m) is called Euler function. Example 2.2. ϕ(5) = #{1,2,3,4} = 4 (2.15) ϕ(8) = #{1,3,5,7} = 4. (2.16)

8 8 CHAPTER 2. THEOREMS Theorem 2.2 (Euler s formula). When gcd(a,m) = 1, we have a ϕ(m) 1 mod m. (2.17) Lemma 2.2. Let gcd(a,m) = 1, and 1 b 1 < b 2 < < b ϕ(m) m be the integer which is relatively prime to m. Then, {ab 1,ab 2,ab 3,...,ab ϕ(m) mod m} = {b 1,b 2,b 3,...,b ϕ(m) mod m}. (2.18) Proof. Assume m and ab j mod m have the common divisor p 1, i.e. m = pq, ab j = pr mod m, for some q and r. Since gcd(a,m) = 1, a shouldn t have the component p. Also b j is relatively prime to m. This is contradiction, so m and ab j are relatively prime. Thus, it is sufficient to prove all the elements in the left hand side are different. Suppose for some 1 j,k ϕ(m). Then, b j a b k a mod m, (2.19) (b j b k )a 0 mod m. (2.20) Since a and m are relatively prime, b j b k = 0 mod m. Since b j b k < m, b j b k = 0. Proof of Euler s formula. By Lemma 2.2, the product of all elements is equal, and a ϕ(m) B B mod m, (2.21) where B = b 1 b ϕ(m). Since all b i are relatively prime to m, B is also relatively prime to m. Thus a ϕ(m) 1 mod m. (2.22) Theorem 2.3. When gcd(m,n) = 1, we have ϕ(mn) = ϕ(m)ϕ(n). (2.23) Proof. By Definition, ϕ(mn) = #A = #{a : 1 a mn,gcd(a,m) = 1}. (2.24) Now ϕ(m)ϕ(n) = #B (2.25) = #{(b,c) : 1 b m,gcd(b,m) = 1,1 c n,gcd(c,n) = 1}. (2.26)

9 2.3. PRIME NUMBER 9 We will show that the elements in these sets has one-to-one relation as Pick a 1,a 2 A with a mod mn (a mod m,a mod n). (2.27) a 1 a 2 mod m, (2.28) a 1 a 2 mod n. (2.29) Hence, a 1 a 2 can be divided by m as well as n. Since m and n are relatively prime, a 1 a 2 should be divided by mn. Thus, a 1 a 2 mod mn. (2.30) On the other hand, from Chinese remainder theorem, given b and c, we know that at least one integer a such as a b mod m (2.31) a c mod n. (2.32) Thus the two set A and B are one-to-one, so the numbers of elements are equal. Example 2.3. ϕ(14) = 6, (2.33) ϕ(15) = 8, (2.34) ϕ(210) = 48. (2.35) 2.3 Prime Number Theorem 2.4. Prime numbers are infinitely many. Proof. Assume you have obtained the finite list of prime numbers. We show how to add a new prime number to the list. Suppose we have such list as Set A = {p 1, p 2,..., p r }. (2.36) a = p 1 p 2 p r + 1. (2.37) If a is a prime number, since a is larger than any prime numbers in A, you can add it to the list A. Suppose a is not a prime number, then we have prime numbers which divide a. Set q is the smallest of those prime numbers. Since a cannot be divided by any prime numbers in A, q is not on the list. In this way, we can keep adding a new prime number to our list.

10 Chapter 3 Theory of RSA 3.1 Power in Modular Problem 3.1. Estimate the following large power in modular: mod 853 (3.1) Solution 3.1. First, find the the second power expression of = = = Then, = = (3.2) Now, recursively we obtain, 7 = 7 mod = 49 mod = 49 2 = 2401 = 695 mod = = = 227 mod = = = 349 mod = = = 675 mod = = = 123 mod = = = 628 mod = = = 298 mod

11 3.2. POWER ROOT IN MODULAR 11 Using these relation in (3.2), we have Remark 3.1. If you have to estimate = = 286 mod 853. a k mod m, (3.3) in the same procedure above, it is only required as much steps as the order of log 2 (k). That means the above procedure is efficient for even large power k. Exercise 3.1. Estimate the following: 5 13 mod 23 (3.4) 3.2 Power Root in Modular Now we proceed to power root in modular. Problem 3.2. Given b, find x satisfying where gcd(b, m) = 1 and gcd(k, ϕ(m)) = 1. x k b mod m, (3.5) Solution to Problem 3.2. Continue replacing x = 0,1,2,... (Check how many steps will be required in worst case.) Another solution to Problem 3.2. We can use Euler function! 1. Estimate Euler function ϕ(m). 2. Find a pair of positive integer u and v which satisfy ku ϕ(m)v = gcd(k,ϕ(m)) = 1. (3.6) Here we can use extended Euclidian algorithm. 3. The solution is x = b u mod m. (3.7) Here we can use the procedure given in Section 3.1.

12 12 CHAPTER 3. THEORY OF RSA Here s why this will give us the solution? x k = (b u ) k = b uk = b 1+ϕ(m)v = b (b ϕ(m) ) v, where we used (3.26). Since gcd(b,m) = 1, we can use Euler s formula (Theorem 2.2), and Thus, we have b ϕ(m) = 1 mod m. (3.8) x k = b mod m. (3.9) Remark 3.2. The important point is how to estimate ϕ(m). If we know the factorization of m into prime, the estimation is relatively easy. For example, if we have the factorization, then we can use Theorem 2.3, and m = pq, (3.10) ϕ(m) = ϕ(p)ϕ(q) = (p 1)(q 1) (3.11) Indeed the factorization is known to be one of the notoriously hard problem. Example 3.1. Find x satisfying x 131 mod (3.12) First we need to find the factorization of 1073, which is 1073 = Thus, ϕ(1073) = = (3.13) Next, we need to find a pair of positive integers (u,v) satisfying We can find (u,v) by extended Euclidean algorithm and ku ϕ(m)v = 1. (3.14) 131u 1008v = 1. (3.15) 131 ( 277) 1008 ( 36) = 1. (3.16) The pair should be positive. If (x 1,y 1 ) is the solution of ax + by = 1. (3.17)

13 3.3. RSA 13 Then, (x 1 b,y 1 + a) is also the solution of the equation. a(x 1 b) + b(y 1 + a) = ax 1 + by 1 = 1. (3.18) Thus, we can adjust the pair by (u,v) = ( , ) = (731,95), (3.19) where, we have = 1. (3.20) Thus, we have x 758 u mod (3.21) Exercise 3.2. Find the solutions: 1. x 329 = 452 mod (3.22) 2. x 113 = 347 mod 463. (3.23) 3.3 RSA Let a be the message to be encrypted. The following is the procedure to encrypt the message a. 1. Pick two large prime numbers p and q. 2. Set m = pq. 3. Derive the Euler function ϕ(m) as ϕ(m) = ϕ(p)ϕ(q) = (p 1)(q 1). (3.24) 4. Pick the encryption key k which is relatively prime to ϕ(m). 5. Encrypt the message a by b = a k (3.25) When you receive the encrypted message, you can decrypt the message by using the method described in Section 3.2.

14 14 CHAPTER 3. THEORY OF RSA 1. Find a pair of positive integer u and v which satisfy by extended Euclidian algorithm. 2. The solution is ku ϕ(m)v = gcd(k,ϕ(m)) = 1, (3.26) x = b u mod m. (3.27) Exercise 3.3. We know that the number 5192,2604,4222 are encrypted by m = 7081 and k = Decrypt the numbers.

Number Theory Proof Portfolio

Number Theory Proof Portfolio Number Theory Proof Portfolio Jordan Rock May 12, 2015 This portfolio is a collection of Number Theory proofs and problems done by Jordan Rock in the Spring of 2014. The problems are organized first by

More information

Number Theory Notes Spring 2011

Number Theory Notes Spring 2011 PRELIMINARIES The counting numbers or natural numbers are 1, 2, 3, 4, 5, 6.... The whole numbers are the counting numbers with zero 0, 1, 2, 3, 4, 5, 6.... The integers are the counting numbers and zero

More information

ECE596C: Handout #11

ECE596C: Handout #11 ECE596C: Handout #11 Public Key Cryptosystems Electrical and Computer Engineering, University of Arizona, Loukas Lazos Abstract In this lecture we introduce necessary mathematical background for studying

More information

Lecture 4: Number theory

Lecture 4: Number theory Lecture 4: Number theory Rajat Mittal IIT Kanpur In the next few classes we will talk about the basics of number theory. Number theory studies the properties of natural numbers and is considered one of

More information

Basic elements of number theory

Basic elements of number theory Cryptography Basic elements of number theory Marius Zimand 1 Divisibility, prime numbers By default all the variables, such as a, b, k, etc., denote integer numbers. Divisibility a 0 divides b if b = a

More information

Basic elements of number theory

Basic elements of number theory Cryptography Basic elements of number theory Marius Zimand By default all the variables, such as a, b, k, etc., denote integer numbers. Divisibility a 0 divides b if b = a k for some integer k. Notation

More information

Congruence Classes. Number Theory Essentials. Modular Arithmetic Systems

Congruence Classes. Number Theory Essentials. Modular Arithmetic Systems Cryptography Introduction to Number Theory 1 Preview Integers Prime Numbers Modular Arithmetic Totient Function Euler's Theorem Fermat's Little Theorem Euclid's Algorithm 2 Introduction to Number Theory

More information

Number Theory and Group Theoryfor Public-Key Cryptography

Number Theory and Group Theoryfor Public-Key Cryptography Number Theory and Group Theory for Public-Key Cryptography TDA352, DIT250 Wissam Aoudi Chalmers University of Technology November 21, 2017 Wissam Aoudi Number Theory and Group Theoryfor Public-Key Cryptography

More information

Mathematics of Cryptography

Mathematics of Cryptography Modulo arithmetic Fermat's Little Theorem If p is prime and 0 < a < p, then a p 1 = 1 mod p Ex: 3 (5 1) = 81 = 1 mod 5 36 (29 1) = 37711171281396032013366321198900157303750656 = 1 mod 29 (see http://gauss.ececs.uc.edu/courses/c472/java/fermat/fermat.html)

More information

MATH 145 Algebra, Solutions to Assignment 4

MATH 145 Algebra, Solutions to Assignment 4 MATH 145 Algebra, Solutions to Assignment 4 1: a) Find the inverse of 178 in Z 365. Solution: We find s and t so that 178s + 365t = 1, and then 178 1 = s. The Euclidean Algorithm gives 365 = 178 + 9 178

More information

ALG 4.0 Number Theory Algorithms:

ALG 4.0 Number Theory Algorithms: Algorithms Professor John Reif ALG 4.0 Number Theory Algorithms: (a) GCD (b) Multiplicative Inverse (c) Fermat & Euler's Theorems (d) Public Key Cryptographic Systems (e) Primality Testing Greatest Common

More information

CPSC 467b: Cryptography and Computer Security

CPSC 467b: Cryptography and Computer Security CPSC 467b: Cryptography and Computer Security Michael J. Fischer Lecture 8 February 1, 2012 CPSC 467b, Lecture 8 1/42 Number Theory Needed for RSA Z n : The integers mod n Modular arithmetic GCD Relatively

More information

ICS141: Discrete Mathematics for Computer Science I

ICS141: Discrete Mathematics for Computer Science I ICS141: Discrete Mathematics for Computer Science I Dept. Information & Computer Sci., Jan Stelovsky based on slides by Dr. Baek and Dr. Still Originals by Dr. M. P. Frank and Dr. J.L. Gross Provided by

More information

This is a recursive algorithm. The procedure is guaranteed to terminate, since the second argument decreases each time.

This is a recursive algorithm. The procedure is guaranteed to terminate, since the second argument decreases each time. 8 Modular Arithmetic We introduce an operator mod. Let d be a positive integer. For c a nonnegative integer, the value c mod d is the remainder when c is divided by d. For example, c mod d = 0 if and only

More information

For your quiz in recitation this week, refer to these exercise generators:

For your quiz in recitation this week, refer to these exercise generators: Monday, Oct 29 Today we will talk about inverses in modular arithmetic, and the use of inverses to solve linear congruences. For your quiz in recitation this week, refer to these exercise generators: GCD

More information

Public Key Cryptography

Public Key Cryptography Public Key Cryptography Spotlight on Science J. Robert Buchanan Department of Mathematics 2011 What is Cryptography? cryptography: study of methods for sending messages in a form that only be understood

More information

A Readable Introduction to Real Mathematics

A Readable Introduction to Real Mathematics Solutions to selected problems in the book A Readable Introduction to Real Mathematics D. Rosenthal, D. Rosenthal, P. Rosenthal Chapter 7: The Euclidean Algorithm and Applications 1. Find the greatest

More information

Senior Math Circles Cryptography and Number Theory Week 2

Senior Math Circles Cryptography and Number Theory Week 2 Senior Math Circles Cryptography and Number Theory Week 2 Dale Brydon Feb. 9, 2014 1 Divisibility and Inverses At the end of last time, we saw that not all numbers have inverses mod n, but some do. We

More information

Number theory (Chapter 4)

Number theory (Chapter 4) EECS 203 Spring 2016 Lecture 10 Page 1 of 8 Number theory (Chapter 4) Review Questions: 1. Does 5 1? Does 1 5? 2. Does (129+63) mod 10 = (129 mod 10)+(63 mod 10)? 3. Does (129+63) mod 10 = ((129 mod 10)+(63

More information

Elementary Number Theory MARUCO. Summer, 2018

Elementary Number Theory MARUCO. Summer, 2018 Elementary Number Theory MARUCO Summer, 2018 Problem Set #0 axiom, theorem, proof, Z, N. Axioms Make a list of axioms for the integers. Does your list adequately describe them? Can you make this list as

More information

Elementary Number Theory Review. Franz Luef

Elementary Number Theory Review. Franz Luef Elementary Number Theory Review Principle of Induction Principle of Induction Suppose we have a sequence of mathematical statements P(1), P(2),... such that (a) P(1) is true. (b) If P(k) is true, then

More information

Number Theory. CSS322: Security and Cryptography. Sirindhorn International Institute of Technology Thammasat University CSS322. Number Theory.

Number Theory. CSS322: Security and Cryptography. Sirindhorn International Institute of Technology Thammasat University CSS322. Number Theory. CSS322: Security and Cryptography Sirindhorn International Institute of Technology Thammasat University Prepared by Steven Gordon on 29 December 2011 CSS322Y11S2L06, Steve/Courses/2011/S2/CSS322/Lectures/number.tex,

More information

basics of security/cryptography

basics of security/cryptography RSA Cryptography basics of security/cryptography Bob encrypts message M into ciphertext C=P(M) using a public key; Bob sends C to Alice Alice decrypts ciphertext back into M using a private key (secret)

More information

Applied Cryptography and Computer Security CSE 664 Spring 2017

Applied Cryptography and Computer Security CSE 664 Spring 2017 Applied Cryptography and Computer Security Lecture 11: Introduction to Number Theory Department of Computer Science and Engineering University at Buffalo 1 Lecture Outline What we ve covered so far: symmetric

More information

CSC 474 Network Security. Outline. GCD and Euclid s Algorithm. GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation Discrete Logarithms

CSC 474 Network Security. Outline. GCD and Euclid s Algorithm. GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation Discrete Logarithms Computer Science CSC 474 Network Security Topic 5.1 Basic Number Theory -- Foundation of Public Key Cryptography CSC 474 Dr. Peng Ning 1 Outline GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation

More information

4 Powers of an Element; Cyclic Groups

4 Powers of an Element; Cyclic Groups 4 Powers of an Element; Cyclic Groups Notation When considering an abstract group (G, ), we will often simplify notation as follows x y will be expressed as xy (x y) z will be expressed as xyz x (y z)

More information

Part IA Numbers and Sets

Part IA Numbers and Sets Part IA Numbers and Sets Theorems Based on lectures by A. G. Thomason Notes taken by Dexter Chua Michaelmas 2014 These notes are not endorsed by the lecturers, and I have modified them (often significantly)

More information

CS 5319 Advanced Discrete Structure. Lecture 9: Introduction to Number Theory II

CS 5319 Advanced Discrete Structure. Lecture 9: Introduction to Number Theory II CS 5319 Advanced Discrete Structure Lecture 9: Introduction to Number Theory II Divisibility Outline Greatest Common Divisor Fundamental Theorem of Arithmetic Modular Arithmetic Euler Phi Function RSA

More information

Outline. Some Review: Divisors. Common Divisors. Primes and Factors. b divides a (or b is a divisor of a) if a = mb for some m

Outline. Some Review: Divisors. Common Divisors. Primes and Factors. b divides a (or b is a divisor of a) if a = mb for some m Outline GCD and Euclid s Algorithm AIT 682: Network and Systems Security Topic 5.1 Basic Number Theory -- Foundation of Public Key Cryptography Modulo Arithmetic Modular Exponentiation Discrete Logarithms

More information

Outline. AIT 682: Network and Systems Security. GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation Discrete Logarithms

Outline. AIT 682: Network and Systems Security. GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation Discrete Logarithms AIT 682: Network and Systems Security Topic 5.1 Basic Number Theory -- Foundation of Public Key Cryptography Instructor: Dr. Kun Sun Outline GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation

More information

a the relation arb is defined if and only if = 2 k, k

a the relation arb is defined if and only if = 2 k, k DISCRETE MATHEMATICS Past Paper Questions in Number Theory 1. Prove that 3k + 2 and 5k + 3, k are relatively prime. (Total 6 marks) 2. (a) Given that the integers m and n are such that 3 (m 2 + n 2 ),

More information

CPSC 467b: Cryptography and Computer Security

CPSC 467b: Cryptography and Computer Security CPSC 467b: Cryptography and Computer Security Michael J. Fischer Lecture 9 February 14, 2013 CPSC 467b, Lecture 9 1/42 Integer Division (cont.) Relatively prime numbers, Z n, and φ(n) Computing in Z n

More information

Public Key Encryption

Public Key Encryption Public Key Encryption 3/13/2012 Cryptography 1 Facts About Numbers Prime number p: p is an integer p 2 The only divisors of p are 1 and p s 2, 7, 19 are primes -3, 0, 1, 6 are not primes Prime decomposition

More information

Numbers. Çetin Kaya Koç Winter / 18

Numbers. Çetin Kaya Koç   Winter / 18 Çetin Kaya Koç http://koclab.cs.ucsb.edu Winter 2016 1 / 18 Number Systems and Sets We represent the set of integers as Z = {..., 3, 2, 1,0,1,2,3,...} We denote the set of positive integers modulo n as

More information

AN ALGEBRAIC PROOF OF RSA ENCRYPTION AND DECRYPTION

AN ALGEBRAIC PROOF OF RSA ENCRYPTION AND DECRYPTION AN ALGEBRAIC PROOF OF RSA ENCRYPTION AND DECRYPTION Recall that RSA works as follows. A wants B to communicate with A, but without E understanding the transmitted message. To do so: A broadcasts RSA method,

More information

2 More on Congruences

2 More on Congruences 2 More on Congruences 2.1 Fermat s Theorem and Euler s Theorem definition 2.1 Let m be a positive integer. A set S = {x 0,x 1,,x m 1 x i Z} is called a complete residue system if x i x j (mod m) whenever

More information

Number Theory & Modern Cryptography

Number Theory & Modern Cryptography Number Theory & Modern Cryptography Week 12 Stallings: Ch 4, 8, 9, 10 CNT-4403: 2.April.2015 1 Introduction Increasing importance in cryptography Public Key Crypto and Signatures Concern operations on

More information

Number Theory and Algebra: A Brief Introduction

Number Theory and Algebra: A Brief Introduction Number Theory and Algebra: A Brief Introduction Indian Statistical Institute Kolkata May 15, 2017 Elementary Number Theory: Modular Arithmetic Definition Let n be a positive integer and a and b two integers.

More information

Number Theory A focused introduction

Number Theory A focused introduction Number Theory A focused introduction This is an explanation of RSA public key cryptography. We will start from first principles, but only the results that are needed to understand RSA are given. We begin

More information

Wilson s Theorem and Fermat s Little Theorem

Wilson s Theorem and Fermat s Little Theorem Wilson s Theorem and Fermat s Little Theorem Wilson stheorem THEOREM 1 (Wilson s Theorem): (p 1)! 1 (mod p) if and only if p is prime. EXAMPLE: We have (2 1)!+1 = 2 (3 1)!+1 = 3 (4 1)!+1 = 7 (5 1)!+1 =

More information

Course MA2C02, Hilary Term 2013 Section 9: Introduction to Number Theory and Cryptography

Course MA2C02, Hilary Term 2013 Section 9: Introduction to Number Theory and Cryptography Course MA2C02, Hilary Term 2013 Section 9: Introduction to Number Theory and Cryptography David R. Wilkins Copyright c David R. Wilkins 2000 2013 Contents 9 Introduction to Number Theory 63 9.1 Subgroups

More information

A SURVEY OF PRIMALITY TESTS

A SURVEY OF PRIMALITY TESTS A SURVEY OF PRIMALITY TESTS STEFAN LANCE Abstract. In this paper, we show how modular arithmetic and Euler s totient function are applied to elementary number theory. In particular, we use only arithmetic

More information

Chapter 9 Basic Number Theory for Public Key Cryptography. WANG YANG

Chapter 9 Basic Number Theory for Public Key Cryptography. WANG YANG Chapter 9 Basic Number Theory for Public Key Cryptography WANG YANG wyang@njnet.edu.cn Content GCD and Euclid s Algorithm Modular Arithmetic Modular Exponentiation Discrete Logarithms GCD and Euclid s

More information

Introduction to Cybersecurity Cryptography (Part 5)

Introduction to Cybersecurity Cryptography (Part 5) Introduction to Cybersecurity Cryptography (Part 5) Prof. Dr. Michael Backes 13.01.2017 February 17 th Special Lecture! 45 Minutes Your Choice 1. Automotive Security 2. Smartphone Security 3. Side Channel

More information

Math 412: Number Theory Lecture 13 Applications of

Math 412: Number Theory Lecture 13 Applications of Math 412: Number Theory Lecture 13 Applications of Gexin Yu gyu@wm.edu College of William and Mary Partition of integers A partition λ of the positive integer n is a non increasing sequence of positive

More information

Addition. Ch1 - Algorithms with numbers. Multiplication. al-khwārizmī. al-khwārizmī. Division 53+35=88. Cost? (n number of bits) 13x11=143. Cost?

Addition. Ch1 - Algorithms with numbers. Multiplication. al-khwārizmī. al-khwārizmī. Division 53+35=88. Cost? (n number of bits) 13x11=143. Cost? Ch - Algorithms with numbers Addition Basic arithmetic Addition ultiplication Division odular arithmetic factoring is hard Primality testing 53+35=88 Cost? (n number of bits) O(n) ultiplication al-khwārizmī

More information

Course 2BA1: Trinity 2006 Section 9: Introduction to Number Theory and Cryptography

Course 2BA1: Trinity 2006 Section 9: Introduction to Number Theory and Cryptography Course 2BA1: Trinity 2006 Section 9: Introduction to Number Theory and Cryptography David R. Wilkins Copyright c David R. Wilkins 2006 Contents 9 Introduction to Number Theory and Cryptography 1 9.1 Subgroups

More information

Homework #2 solutions Due: June 15, 2012

Homework #2 solutions Due: June 15, 2012 All of the following exercises are based on the material in the handout on integers found on the class website. 1. Find d = gcd(475, 385) and express it as a linear combination of 475 and 385. That is

More information

2 Arithmetic. 2.1 Greatest common divisors. This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}.

2 Arithmetic. 2.1 Greatest common divisors. This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}. 2 Arithmetic This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}. (See [Houston, Chapters 27 & 28]) 2.1 Greatest common divisors Definition 2.16. If a, b are integers, we say

More information

Introduction to Public-Key Cryptosystems:

Introduction to Public-Key Cryptosystems: Introduction to Public-Key Cryptosystems: Technical Underpinnings: RSA and Primality Testing Modes of Encryption for RSA Digital Signatures for RSA 1 RSA Block Encryption / Decryption and Signing Each

More information

Chapter 5.1: Induction

Chapter 5.1: Induction Chapter.1: Induction Monday, July 1 Fermat s Little Theorem Evaluate the following: 1. 1 (mod ) 1 ( ) 1 1 (mod ). (mod 7) ( ) 8 ) 1 8 1 (mod ). 77 (mod 19). 18 (mod 1) 77 ( 18 ) 1 1 (mod 19) 18 1 (mod

More information

CPSC 467: Cryptography and Computer Security

CPSC 467: Cryptography and Computer Security CPSC 467: Cryptography and Computer Security Michael J. Fischer Lecture 14 October 23, 2017 CPSC 467, Lecture 14 1/42 Computing in Z n Modular multiplication Modular inverses Extended Euclidean algorithm

More information

Discrete Mathematics GCD, LCM, RSA Algorithm

Discrete Mathematics GCD, LCM, RSA Algorithm Discrete Mathematics GCD, LCM, RSA Algorithm Abdul Hameed http://informationtechnology.pk/pucit abdul.hameed@pucit.edu.pk Lecture 16 Greatest Common Divisor 2 Greatest common divisor The greatest common

More information

Basic Algorithms in Number Theory

Basic Algorithms in Number Theory Basic Algorithms in Number Theory Algorithmic Complexity... 1 Basic Algorithms in Number Theory Francesco Pappalardi #2-b - Euclidean Algorithm. September 2 nd 2015 SEAMS School 2015 Number Theory and

More information

All variables a, b, n, etc are integers unless otherwise stated. Each part of a problem is worth 5 points.

All variables a, b, n, etc are integers unless otherwise stated. Each part of a problem is worth 5 points. Math 152, Problem Set 2 solutions (2018-01-24) All variables a, b, n, etc are integers unless otherwise stated. Each part of a problem is worth 5 points. 1. Let us look at the following equation: x 5 1

More information

Ma/CS 6a Class 2: Congruences

Ma/CS 6a Class 2: Congruences Ma/CS 6a Class 2: Congruences 1 + 1 5 (mod 3) By Adam Sheffer Reminder: Public Key Cryptography Idea. Use a public key which is used for encryption and a private key used for decryption. Alice encrypts

More information

Introduction to Number Theory 1. c Eli Biham - December 13, Introduction to Number Theory 1

Introduction to Number Theory 1. c Eli Biham - December 13, Introduction to Number Theory 1 Introduction to Number Theory 1 c Eli Biham - December 13, 2012 206 Introduction to Number Theory 1 Division Definition: Let a and b be integers. We say that a divides b, or a b if d s.t. b = ad. If b

More information

Lecture notes: Algorithms for integers, polynomials (Thorsten Theobald)

Lecture notes: Algorithms for integers, polynomials (Thorsten Theobald) Lecture notes: Algorithms for integers, polynomials (Thorsten Theobald) 1 Euclid s Algorithm Euclid s Algorithm for computing the greatest common divisor belongs to the oldest known computing procedures

More information

Know the Well-ordering principle: Any set of positive integers which has at least one element contains a smallest element.

Know the Well-ordering principle: Any set of positive integers which has at least one element contains a smallest element. The first exam will be on Monday, June 8, 202. The syllabus will be sections. and.2 in Lax, and the number theory handout found on the class web site, plus the handout on the method of successive squaring

More information

8. Given a rational number r, prove that there exist coprime integers p and q, with q 0, so that r = p q. . For all n N, f n = an b n 2

8. Given a rational number r, prove that there exist coprime integers p and q, with q 0, so that r = p q. . For all n N, f n = an b n 2 MATH 135: Randomized Exam Practice Problems These are the warm-up exercises and recommended problems taken from all the extra practice sets presented in random order. The challenge problems have not been

More information

Number theory (Chapter 4)

Number theory (Chapter 4) EECS 203 Spring 2016 Lecture 12 Page 1 of 8 Number theory (Chapter 4) Review Compute 6 11 mod 13 in an efficient way What is the prime factorization of 100? 138? What is gcd(100, 138)? What is lcm(100,138)?

More information

CS March 17, 2009

CS March 17, 2009 Discrete Mathematics CS 2610 March 17, 2009 Number Theory Elementary number theory, concerned with numbers, usually integers and their properties or rational numbers mainly divisibility among integers

More information

Signature: (In Ink) UNIVERSITY OF MANITOBA TEST 1 SOLUTIONS COURSE: MATH 2170 DATE & TIME: February 11, 2019, 16:30 17:15

Signature: (In Ink) UNIVERSITY OF MANITOBA TEST 1 SOLUTIONS COURSE: MATH 2170 DATE & TIME: February 11, 2019, 16:30 17:15 PAGE: 1 of 7 I understand that cheating is a serious offence: Signature: (In Ink) PAGE: 2 of 7 1. Let a, b, m, be integers, m > 1. [1] (a) Define a b. Solution: a b iff for some d, ad = b. [1] (b) Define

More information

CS250: Discrete Math for Computer Science

CS250: Discrete Math for Computer Science CS250: Discrete Math for Computer Science L6: Euclid s Algorithm & Multiplicative Inverses Mod m Greatest Common Divisors, GCD If d a and d b then d is a common divisor of a and b. 1, 2, 3, and 6 are common

More information

CHAPTER 6. Prime Numbers. Definition and Fundamental Results

CHAPTER 6. Prime Numbers. Definition and Fundamental Results CHAPTER 6 Prime Numbers Part VI of PJE. Definition and Fundamental Results 6.1. Definition. (PJE definition 23.1.1) An integer p is prime if p > 1 and the only positive divisors of p are 1 and p. If n

More information

cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications

cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications casting out 3s Theorem: A positive integer n is divisible by 3 if and only if the sum of its decimal digits is divisible

More information

Introduction to Cryptography. Lecture 6

Introduction to Cryptography. Lecture 6 Introduction to Cryptography Lecture 6 Benny Pinkas page 1 Public Key Encryption page 2 Classical symmetric ciphers Alice and Bob share a private key k. System is secure as long as k is secret. Major problem:

More information

Introduction to Information Security

Introduction to Information Security Introduction to Information Security Lecture 5: Number Theory 007. 6. Prof. Byoungcheon Lee sultan (at) joongbu. ac. kr Information and Communications University Contents 1. Number Theory Divisibility

More information

NUMBER THEORY AND CODES. Álvaro Pelayo WUSTL

NUMBER THEORY AND CODES. Álvaro Pelayo WUSTL NUMBER THEORY AND CODES Álvaro Pelayo WUSTL Talk Goal To develop codes of the sort can tell the world how to put messages in code (public key cryptography) only you can decode them Structure of Talk Part

More information

Chapter 8 Public-key Cryptography and Digital Signatures

Chapter 8 Public-key Cryptography and Digital Signatures Chapter 8 Public-key Cryptography and Digital Signatures v 1. Introduction to Public-key Cryptography 2. Example of Public-key Algorithm: Diffie- Hellman Key Exchange Scheme 3. RSA Encryption and Digital

More information

Chapter 8. Introduction to Number Theory

Chapter 8. Introduction to Number Theory Chapter 8 Introduction to Number Theory CRYPTOGRAPHY AND NETWORK SECURITY 1 Index 1. Prime Numbers 2. Fermat`s and Euler`s Theorems 3. Testing for Primality 4. Discrete Logarithms 2 Prime Numbers 3 Prime

More information

4 Number Theory and Cryptography

4 Number Theory and Cryptography 4 Number Theory and Cryptography 4.1 Divisibility and Modular Arithmetic This section introduces the basics of number theory number theory is the part of mathematics involving integers and their properties.

More information

ECE 646 Lecture 5. Mathematical Background: Modular Arithmetic

ECE 646 Lecture 5. Mathematical Background: Modular Arithmetic ECE 646 Lecture 5 Mathematical Background: Modular Arithmetic Motivation: Public-key ciphers RSA as a trap-door one-way function PUBLIC KEY message ciphertext M C = f(m) = M e mod N C M = f -1 (C) = C

More information

Carmen s Core Concepts (Math 135)

Carmen s Core Concepts (Math 135) Carmen s Core Concepts (Math 135) Carmen Bruni University of Waterloo Week 8 1 The following are equivalent (TFAE) 2 Inverses 3 More on Multiplicative Inverses 4 Linear Congruence Theorem 2 [LCT2] 5 Fermat

More information

Number theory. Myrto Arapinis School of Informatics University of Edinburgh. October 9, /29

Number theory. Myrto Arapinis School of Informatics University of Edinburgh. October 9, /29 Number theory Myrto Arapinis School of Informatics University of Edinburgh October 9, 2014 1/29 Division Definition If a and b are integers with a 6= 0, then a divides b if there exists an integer c such

More information

3 The fundamentals: Algorithms, the integers, and matrices

3 The fundamentals: Algorithms, the integers, and matrices 3 The fundamentals: Algorithms, the integers, and matrices 3.4 The integers and division This section introduces the basics of number theory number theory is the part of mathematics involving integers

More information

The Chinese Remainder Theorem

The Chinese Remainder Theorem Chapter 5 The Chinese Remainder Theorem 5.1 Coprime moduli Theorem 5.1. Suppose m, n N, and gcd(m, n) = 1. Given any remainders r mod m and s mod n we can find N such that N r mod m and N s mod n. Moreover,

More information

Name: Mathematics 1C03

Name: Mathematics 1C03 Name: Student ID Number: Mathematics 1C03 Day Class Instructor: M. Harada Duration: 2.5 hours April 2018 McMaster University PRACTICE Final Examination This is a PRACTICE final exam. The actual final exam

More information

Beautiful Mathematics

Beautiful Mathematics Beautiful Mathematics 1. Principle of Mathematical Induction The set of natural numbers is the set of positive integers {1, 2, 3,... } and is denoted by N. The Principle of Mathematical Induction is a

More information

a = mq + r where 0 r m 1.

a = mq + r where 0 r m 1. 8. Euler ϕ-function We have already seen that Z m, the set of equivalence classes of the integers modulo m, is naturally a ring. Now we will start to derive some interesting consequences in number theory.

More information

8 Primes and Modular Arithmetic

8 Primes and Modular Arithmetic 8 Primes and Modular Arithmetic 8.1 Primes and Factors Over two millennia ago already, people all over the world were considering the properties of numbers. One of the simplest concepts is prime numbers.

More information

Basic Algorithms in Number Theory

Basic Algorithms in Number Theory Basic Algorithms in Number Theory Algorithmic Complexity... 1 Basic Algorithms in Number Theory Francesco Pappalardi Discrete Logs, Modular Square Roots & Euclidean Algorithm. July 20 th 2010 Basic Algorithms

More information

CRYPTOGRAPHY AND NUMBER THEORY

CRYPTOGRAPHY AND NUMBER THEORY CRYPTOGRAPHY AND NUMBER THEORY XINYU SHI Abstract. In this paper, we will discuss a few examples of cryptographic systems, categorized into two different types: symmetric and asymmetric cryptography. We

More information

Topics in Cryptography. Lecture 5: Basic Number Theory

Topics in Cryptography. Lecture 5: Basic Number Theory Topics in Cryptography Lecture 5: Basic Number Theory Benny Pinkas page 1 1 Classical symmetric ciphers Alice and Bob share a private key k. System is secure as long as k is secret. Major problem: generating

More information

Math 4400/6400 Homework #8 solutions. 1. Let P be an odd integer (not necessarily prime). Show that modulo 2,

Math 4400/6400 Homework #8 solutions. 1. Let P be an odd integer (not necessarily prime). Show that modulo 2, MATH 4400 roblems. Math 4400/6400 Homework # solutions 1. Let P be an odd integer not necessarily rime. Show that modulo, { P 1 0 if P 1, 7 mod, 1 if P 3, mod. Proof. Suose that P 1 mod. Then we can write

More information

10 Modular Arithmetic and Cryptography

10 Modular Arithmetic and Cryptography 10 Modular Arithmetic and Cryptography 10.1 Encryption and Decryption Encryption is used to send messages secretly. The sender has a message or plaintext. Encryption by the sender takes the plaintext and

More information

[Part 2] Asymmetric-Key Encipherment. Chapter 9. Mathematics of Cryptography. Objectives. Contents. Objectives

[Part 2] Asymmetric-Key Encipherment. Chapter 9. Mathematics of Cryptography. Objectives. Contents. Objectives [Part 2] Asymmetric-Key Encipherment Mathematics of Cryptography Forouzan, B.A. Cryptography and Network Security (International Edition). United States: McGraw Hill, 2008. Objectives To introduce prime

More information

1 Overview and revision

1 Overview and revision MTH6128 Number Theory Notes 1 Spring 2018 1 Overview and revision In this section we will meet some of the concerns of Number Theory, and have a brief revision of some of the relevant material from Introduction

More information

OWO Lecture: Modular Arithmetic with Algorithmic Applications

OWO Lecture: Modular Arithmetic with Algorithmic Applications OWO Lecture: Modular Arithmetic with Algorithmic Applications Martin Otto Winter Term 2008/09 Contents 1 Basic ingredients 1 2 Modular arithmetic 2 2.1 Going in circles.......................... 2 2.2

More information

1 Recommended Reading 1. 2 Public Key/Private Key Cryptography Overview RSA Algorithm... 2

1 Recommended Reading 1. 2 Public Key/Private Key Cryptography Overview RSA Algorithm... 2 Contents 1 Recommended Reading 1 2 Public Key/Private Key Cryptography 1 2.1 Overview............................................. 1 2.2 RSA Algorithm.......................................... 2 3 A Number

More information

Introduction to Number Theory. The study of the integers

Introduction to Number Theory. The study of the integers Introduction to Number Theory The study of the integers of Integers, The set of integers = {... 3, 2, 1, 0, 1, 2, 3,...}. In this lecture, if nothing is said about a variable, it is an integer. Def. We

More information

Iterated Encryption and Wiener s attack on RSA

Iterated Encryption and Wiener s attack on RSA Iterated Encryption Euler s function Euler s function: φ(n) = {1 x n : gcd(x, n) = 1} Theorem (Euler) If n is a positive integer and m is a positive integer coprime to n then m φ(n) mod n = 1. Iterated

More information

Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya

Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya BBM 205 Discrete Mathematics Hacettepe University http://web.cs.hacettepe.edu.tr/ bbm205 Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya Resources: Kenneth Rosen,

More information

Ch 4.2 Divisibility Properties

Ch 4.2 Divisibility Properties Ch 4.2 Divisibility Properties - Prime numbers and composite numbers - Procedure for determining whether or not a positive integer is a prime - GCF: procedure for finding gcf (Euclidean Algorithm) - Definition:

More information

9 Modular Exponentiation and Square-Roots

9 Modular Exponentiation and Square-Roots 9 Modular Exponentiation and Square-Roots Modular arithmetic is used in cryptography. In particular, modular exponentiation is the cornerstone of what is called the RSA system. 9. Modular Exponentiation

More information

CPSC 467: Cryptography and Computer Security

CPSC 467: Cryptography and Computer Security CPSC 467: Cryptography and Computer Security Michael J. Fischer Lecture 9 September 30, 2015 CPSC 467, Lecture 9 1/47 Fast Exponentiation Algorithms Number Theory Needed for RSA Elementary Number Theory

More information

A Guide to Arithmetic

A Guide to Arithmetic A Guide to Arithmetic Robin Chapman August 5, 1994 These notes give a very brief resumé of my number theory course. Proofs and examples are omitted. Any suggestions for improvements will be gratefully

More information

Section Summary. Division Division Algorithm Modular Arithmetic

Section Summary. Division Division Algorithm Modular Arithmetic 1 Chapter Motivation Number theory is the part of mathematics devoted to the study of the integers and their properties. Key ideas in number theory include divisibility and the primality of integers. Representations

More information

Ma/CS 6a Class 2: Congruences

Ma/CS 6a Class 2: Congruences Ma/CS 6a Class 2: Congruences 1 + 1 5 (mod 3) By Adam Sheffer Reminder: Public Key Cryptography Idea. Use a public key which is used for encryption and a private key used for decryption. Alice encrypts

More information

1. Given the public RSA encryption key (e, n) = (5, 35), find the corresponding decryption key (d, n).

1. Given the public RSA encryption key (e, n) = (5, 35), find the corresponding decryption key (d, n). MATH 135: Randomized Exam Practice Problems These are the warm-up exercises and recommended problems taken from all the extra practice sets presented in random order. The challenge problems have not been

More information