Docsity

Basic Number Theory: Divisors, Prime Numbers, and Modular Arithmetic - Prof. Ning, Study notes of Cryptography and System Security

Toggle sidebar
bg1
CSC 474 Dr. Peng Ning 1
Computer Science
CSC 474
Information Systems Security
Topic 2.3 Basic Number Theory
CSC 474 Dr. Peng Ning 2
Computer Science
Basic Number Theory
• We are talking about integers!
• Divisor
– We say that b≠0 divides a if a = mb for some m,
denoted b|a. b is a divisor of a.
– If a|1, then a = 1 or –1.
– If a|b and b|a, then a = b or –b.
– Any b≠0 divides 0.
– If b|g and b|h, then b|(mg+nh) for arbitrary
integers m and n.
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Basic Number Theory: Divisors, Prime Numbers, and Modular Arithmetic - Prof. Ning and more Study notes Cryptography and System Security in PDF only on Docsity!

CSC 474 Dr. Peng Ning 1

Computer Science CSC 474

Information Systems Security

Topic 2.3 Basic Number Theory

Basic Number Theory • We are talking about integers!

• Divisor – We say that denoted b | a. bb ≠ is a 0 divides divisor a ofif aa .= mb for some m ,

  • – – IfIfAny aa |1, then| b b and≠0 divides 0. b a | a (^) , then= 1 or a – 1.= b or – b.
  • If integers b | g and m b and| h , then n. b |( mg+nh ) for arbitrary

Computer Science CSC 474 Dr. Peng Ning 3

Basic Number Theory (Cont • Prime numbers ’d)

  • – An integer divisors are 1,Examples: 2, 3, 5, 7, 11, 13, 17, 19, 31, p > 1 is a prime number if its only – 1 , p , and – p. …
  • Any integer a > 1 can be factored in a unique way as – where each p ! – where eachExamples: 91=13^ a^ =^ p^1^ aa^1 p^1 i >0.>^2^ a^2 p^ ...^2 ×> pt^ a 7, 11011=13… t > pt^ are prime numbers and × 112 ×7.

Basic Number Theory (Cont • Another view of a | b : ’d)

  • – LetRepresent P be the set of all prime numbers a as
  • – Represent a | b means that! b as a^ ai ≤=^ b " i.^ p^ # P^ pa^ p^ ,^ where^ ap^ $^ 0. !

b = " (^) p # P pb^ p^ , where bp $ 0.

Computer Science CSC 474 Dr. Peng Ning 7

Modulo Operator (Cont • Properties of modulo operator’d)

  • – – a ( aa ≡≡ mod bb modmod n ) = ( nn ifimplies b (^) n mod|( a – n (^) bb ) implies )≡ a mod an ≡. b mod n.
  • a ≡ b mod n and b ≡ c mod n imply a ≡ c mod n.

Modular Arithmetic • Observation:

  • Modular addition.^ –^ The (mod^ of integers{0, 1, 2,^ n ) operator maps all integers into the set^ …, ( n -1)}.
  • Modular subtraction.^ –^ [( a^ mod^ n ) + ( b^ mod^ n )] mod^ n^ = ( a+b ) mod^ n
  • Modular multiplication.^ – –^ [([( aa^ modmod^ nn ))^ – ×^ (( bb^ modmod^ nn )] mod)] mod^ nn^ = (= ( aa^ – ×^ bb ) mod) mod^ nn

Computer Science CSC 474 Dr. Peng Ning 9

An Exercise (n=5) • Addition • Multiplication

Exponentiation^49210 mod 5 = ____

321

0 0 1 2 3 4 432

10 0 1 2 3 4

Properties of Modular Arithmetic • Z n ={0, 1, …, ( n -1)}

  • • Commutative lawsAssociative laws – – (( w + xw × x ) mod) mod nn = (= ( xx (^) ×+ ww ) mod) mod nn
  • Distributive law^ –^ – –^ [([([ ww + xw ×× ( xx ) ) ++^ × y^ yy )] mod] mod] mod n = [ nn = [(= [ www^ ×+ ( ×^ ( xxx + y )+(^ ×^ yw )] mod)] mod × y )] mod^ nn n
  • • IdentitiesAdditive inverse ( – – (0 +(1 × ww ) mod) mod nn == ww – modmod w ) nn
    • For each w ∈Z n , there exists a z such that w + z =0 mod n.

Computer Science CSC 474 Dr. Peng Ning 13

Totient • Totient Function function ø( n ): number of integers less

than – – IfIf nnn =is prime, ø( and relatively prime to p ∗ q , and p, qn )= are primes, n -1 ø( nn )=( p -1)( q -1)

  • Examples: – – ø(7)=____ø(21)=____

Euler • For every’s Theorem a and n that are relatively prime,

a – ø( Proof leaves as an exercise. n )^ ≡1 mod n.

  • Examples – – a=3, n=10,a=2, n=11, ø(10)= ____ , 3ø(11)=____, 2ø(11)ø(10) (^) mod 11=____. (^) mod 10 = ____

Computer Science CSC 474 Dr. Peng Ning 15

Modular Exponentiation • xy mod n = xy mod ø( n ) mod n

  • • ifExample: y = 1 mod ø( n ) then xy^ mod n = x mod n
    • 2100 mod 33 = ____

Euclid • Observation’s Algorithm

  • – 1.Eulid^ gcdX← ((d; Y a, bd, f ) =←), d fgcd > ( fb, a > 0.^ mod^ b )
        1. If Y = 0 returnR = X mod YX ←Y X=gcd(d, f)
      1. YGoto ←R 2

Computer Science CSC 474 Dr. Peng Ning 19

Understanding The Order of • Powers of Integers Modulo 19 a (mod n )

1898 157 18^718 1^611 18^1612 1^111 18^4^81^17^718^1^18191118512171186811671811181411181712111

742 11164 178 7^916 11^1713 1^117 7^614 11^59 1^118 74^17 1116^15 17^11 79^3 1117^6 111^12 76^5 115^10 11^1

1 a 1 a^2 1 a^3 1 a^4 1 a^5 1 a^6 1 a^7 1 a^8 1 a^9 1 a^10 1 a^11 1 a^12 1 a^13 1 a^14 1 a^15 1 a^16 1 a^17 1^ a^18

Observations in The Previous Table • All sequences end in 1.

  • The length of a sequence divides – Lengths: 1, 2, 3, 6, 9, 18. φ(19) = 18.
  • Some of the sequences are of length 18. – The base integer a generates (via powers) all nonzero integers modulo 19.

Computer Science CSC 474 Dr. Peng Ning 21

Primitive Root • The highest possible order of a (mod n ) is φ( n ).

  • Primitive root – If the order of to as a primitive root a (mod of n ) is n. φ( n ), then a is referred
  • For a prime number^ –^ The powers of^ and are all relatively prime to^ a :^ a ,^ ap^2 , if,^ … a ,^ a is a primitive root n^ -1 n^ .are distinct (mod^ n )

of numbers mod p , then a , a 2 p , .…, a p-1^ are all the distinct

Discrete Logarithm • Given a primitive root a for a prime number p :

  • – The expression integers from 1 to (The exponent i (^) is referred to as b ≡ api^ -1).mod p , 0≤ i the index of ≤( p -1), produces the b for the base a
  • – (modindind a,pa,p^ (1)=0, because( pa ))=1, because, denoted as^ ind aa^01 modmod a,p ( b ). pp = 1.= a.
  • Example: – Integer 2 is a primitive root of prime number 19 IndexNumberIndex 17100 12111 151213 5132 71416 111514 4166 10173 9188

Number 1 2 3 4 5 6 7 8 9