15
CSS441 Number Theory Primes Modular Arithmetic 1/15 Number Theory CSS441: Security and Cryptography Sirindhorn International Institute of Technology Thammasat University Prepared by Steven Gordon on 20 December 2015 css441y15s2l06, Steve/Courses/2015/s2/css441/lectures/number-theory.tex, r4295

Primes Arithmetic Number Theory - sandilands.info

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Primes Arithmetic Number Theory - sandilands.info

CSS441

Number Theory

Primes

ModularArithmetic

1/15

Number Theory

CSS441: Security and Cryptography

Sirindhorn International Institute of TechnologyThammasat University

Prepared by Steven Gordon on 20 December 2015css441y15s2l06, Steve/Courses/2015/s2/css441/lectures/number-theory.tex, r4295

Page 2: Primes Arithmetic Number Theory - sandilands.info

CSS441

Number Theory

Primes

ModularArithmetic

2/15

Contents

Divisibility and Prime Numbers

Modular Arithmetic

Page 3: Primes Arithmetic Number Theory - sandilands.info

CSS441

Number Theory

Primes

ModularArithmetic

3/15

Divisibility

I b divides a if a = mb for some m, where a, b and m areintegers

I b|aI b is a divisor of a

I gcd(a, b): greatest common divisor of a and bI Euclidean algorithm can find gcd

I Two integers, a and b, are relatively prime ifgcd(a, b) = 1

Page 4: Primes Arithmetic Number Theory - sandilands.info

CSS441

Number Theory

Primes

ModularArithmetic

4/15

Prime Numbers

I An integer p > 1 is a prime number if and only if itsonly divisors are ±1 and ±p

I Any integer a > 1 can be factored as:

a = pa12 × pa22 × · · · × patt

where p1 < p2 < . . . < pt are prime numbers and whereeach ai is a positive integer

Page 5: Primes Arithmetic Number Theory - sandilands.info

CSS441

Number Theory

Primes

ModularArithmetic

5/15

Primes Under 2000

Page 6: Primes Arithmetic Number Theory - sandilands.info

CSS441

Number Theory

Primes

ModularArithmetic

6/15

Contents

Divisibility and Prime Numbers

Modular Arithmetic

Page 7: Primes Arithmetic Number Theory - sandilands.info

CSS441

Number Theory

Primes

ModularArithmetic

7/15

Modular Arithmetic

I If a is an integer and n is a positive integer, we definea mod n to be the remainder when a is divided by n

I n is called the modulus

I Two integers a and b are congruent modulo n if(a mod n) = (b mod n), which is written as

a ≡ b (mod n)

I (mod n) operator maps all integers into the set ofintegers Zn = {0, 1, . . . , (n − 1)}

I Modular arithmetic performs arithmetic operationswithin confines of set Zn

Page 8: Primes Arithmetic Number Theory - sandilands.info

CSS441

Number Theory

Primes

ModularArithmetic

8/15

Properties of Modular Arithmetic

I Rules of ordinary arithmetic involving addition,subtraction, and multiplication also apply in modulararithmetic

[(a mod n) + (b mod n)] mod n = (a + b) mod n

[(a mod n)− (b mod n)] mod n = (a− b) mod n

[(a mod n)× (b mod n)] mod n = (a× b) mod n

Credit: Table 4.3 in Stallings, Cryptography and Network Security, 5th Ed., Pearson 2011

Page 9: Primes Arithmetic Number Theory - sandilands.info

CSS441

Number Theory

Primes

ModularArithmetic

9/15

Division in Modular Arithmetic

I a is additive inverse of b if a + b ≡ 0 (mod n)I All integers have an additive inverse

I a is multiplicative inverse of b if a× b ≡ 1 (mod n)I Not all integers have a multiplicative inverseI a has a multiplicative inverse in (mod n) if a is

relatively prime to n

I Division: a÷ b ≡ a×MultInverse(b) (mod n)

Page 10: Primes Arithmetic Number Theory - sandilands.info

CSS441

Number Theory

Primes

ModularArithmetic

10/15

Fermat’s Theorem

I Fermat’s Theorem (1): if p is prime and a is a positiveinteger not divisible by p, then

ap−1 ≡ 1 (mod p)

I Fermat’s Theorem (2): if p is prime and a is a positiveinteger, then

ap ≡ a (mod p)

Page 11: Primes Arithmetic Number Theory - sandilands.info

CSS441

Number Theory

Primes

ModularArithmetic

11/15

Euler’s Theorem

I Euler’s Totient Function, φ(n): the number of positiveintegers less than n and relatively prime to n

I φ(1) = 1I For prime p, φ(p) = p − 1I For primes p and q, and n = pq,φ(n) = (p − 1)× (q − 1)

I Euler’s Theorem (1): For every a and n that arerelatively prime:

aφ(n) ≡ 1 (mod n)

I Euler’s Theorem (2): For positive integers a and n:

aφ(n)+1 ≡ a (mod n)

Page 12: Primes Arithmetic Number Theory - sandilands.info

CSS441

Number Theory

Primes

ModularArithmetic

12/15

Logarithms in Modular Arithmetic

I Exponentiation (mod n): repeated multiplication

I Logarithms in ordinary arithmetic:

b = ai

i = loga(b)

I Logarithms in modular arithmetic (discrete logarithm):

b = ai (mod p)

i = dloga,p(b)

I A unique exponent i can be found if a is a primitiveroot of prime p

I If a is a primitive root of p then a, a2, a3, . . . , ap−1 aredistinct (modp)

I Only integers with primitive roots: 2, 4, pα, 2pα wherep is any odd prime and alpha is positive integer

Page 13: Primes Arithmetic Number Theory - sandilands.info

CSS441

Number Theory

Primes

ModularArithmetic

13/15

Powers of Integers, Modulo 19

Credit: Table 8.3 in Stallings, Cryptography and Network Security, 5th Ed., Pearson 2011

Page 14: Primes Arithmetic Number Theory - sandilands.info

CSS441

Number Theory

Primes

ModularArithmetic

14/15

Discrete Logarithms, Modulo 19

Credit: Table 8.4 in Stallings, Cryptography and Network Security, 5th Ed., Pearson 2011

Page 15: Primes Arithmetic Number Theory - sandilands.info

CSS441

Number Theory

Primes

ModularArithmetic

15/15

Complexity

Certain problems are computationally hard . . .

Integer Factorisation

I If p and q are unknown primes, given n = pq, find pand q

I Largest RSA number factored into two primes is 768bits (232 decimal digits)

Euler’s Totient

I Given composite n, find φ(n)

I Harder than integer factorisation

Discrete Logarithms

I Given b, a and p, find i such that i = dloga,p(b)

I Comparable to integer factorisation