Integers and Algorithms Applications of Number Theory - PowerPoint PPT Presentation

1 / 33
About This Presentation
Title:

Integers and Algorithms Applications of Number Theory

Description:

... 3 propositions, p, q and r. The lemma states that the compound proposition p q r ... q m | (a b) (by Lemma 1). But this means that a b (mod m) QED. Observations: ... – PowerPoint PPT presentation

Number of Views:201
Avg rating:3.0/5.0
Slides: 34
Provided by: isabellebi
Category:

less

Transcript and Presenter's Notes

Title: Integers and Algorithms Applications of Number Theory


1
Integers and AlgorithmsApplications of Number
Theory
2
Learning Objectives
  • Understand how to calculate the Greatest Common
    divisor using the Euclidean division algorithm.
  • Understand algorithm to calculate base expansion
    of an integer.

3
Learning Objectives
  • Understand some applications of number theory
  • computer arithmetic with large numbers
  • public key cryptography

4
Integers and Algorithms
  • Euclidean algorithmEuclid proposed this
    algorithm to calculate the gcd of two
    numbers.Let abqr, where a,b,q,r are integers.
    Then gcd(a,b)gcd(b,r).If d divides a and b, it
    divides also r because ra-bq. So all common
    divisor of a and b is also a common divisor of b
    and r.If d divides b and r, it divides also a
    because abqr. So all common divisors of b and r
    are also common divisors of a and b.
  • Examplegcd(662,414) gcd(414,248)
    gcd(248,166) gcd(166,82) gcd(82,2) 2

5
Integers and Algorithms
  • Algorithm procedure gcd(a,b positive
    integers)x ay bwhile y gt 0begin r x
    mod y x y y rend gcd(a,b) is x

6
Integers and Algorithms
  • Base b expansion representation of n such that
  • where n is a positive integer, k is
    a nonnegative integer, a0, a1, , ak
    are nonnegative integers lt b
  • ak ? 0
  • Example binary expansion, where all digits are
    either 0 or 1. Hexadecimal expansion, where all
    digits are 0,1, , 9, A, B, C, D, E, F

7
Integers and Algorithms
  • Examples
  • (101011)2 25 23 21 20 43
  • 145 (10010001) 2
  • (3A5)16 3.162 10.161 5
  • 145 (91)16

8
Integers and Algorithms
  • Algorithmprocedure base b expansion(npositive
    integer)q nk 0while q gt 0begin ak
    q mod b q ?q/b ? k k 1end the
    base b expansion of n is (aka0)b

9
Integers and Algorithms
  • Integer operations algorithms to perform
    operations directly on binary expansions.
  • Example addition O(n)
  • procedure add(a,bpositive integers)c 0for
    j 0 to n-1begin d ?(aj bj c)/2 ?
    sj aj bj c - 2d d is the next
    carry c dendsn c the binary
    expansion of the sum is (snsn-1 s1s0)2

10
Applications of Number Theory
  • Theorem 1 if a and b are positive integers,
    then there exist integers s and t such that
    gcd(a,b) sa yb (This is called the Extended
    Euclidean Algorithm). The gcd can be expressed as
    a linear combination of a and b.
  • Examplegcd(57, 23)
  • Execute the Euclidean algorithm keeping track of
    the quotients and remainders
  • r0 57, r1 23
  • 57 23 . 2 11 r2 11 q1 2
  • 23 11 . 2 1 r3 1 q2 2
  • 11 11 . 1 0 r4 0 q3 1
  • gcd (57,23) 1 (the last not null remainder).
  • To obtain the desired linear combination
  • 23 11.2 1 gt 1 23 2. 11
  • 57 23.2 11 gt 11 57 2. 23
  • Thus gcd(57,23) 1 23 2. 11 23 2.(57
    2.23) -2. 57 5.23

11
Applications of Number Theory
  • Definition if ab mod c 1 we say that a is the
    inverse of b mod c. Can also be written ab ? 1
    (mod c).
  • Note If a has an inverse mod c, then it has an
    inverse which is lt c. Indeed if b is an inverse
    of a MOD c then so are all the integers b nc.
  • A 1,2,4,5,8,10,11,13,16,17,19,20 are all the
    integers lt 21 that are relatively prime to 21.
    That is ?n?A (gcd(21,n) 1).
  • Note 2x11 mod 21 1 8x8 1 mod 21 5x17
    1 mod 21. A little more effort and you can
    quickly check that ?n ? A ?m (nm mod 21 1). (In
    words every member of A has an inverse mod 21
    belonging to A).

12
Applications of Number Theory
  • Lemma 1 a,b and c are positive integers.
    gcd(a,b) 1 (p) and a bc (q) then a c (r).
  • (We have here 3 propositions, p, q and r. The
    lemma states that the compound proposition p ? q
    ? r is TRUE).
  • Proof
  • p ? 1 sa tb (Theorem 1).
  • c sac tbc (multiplication by c)
  • since a bc (q) a sac ? a tbc
  • thus a sac tbc c. QED.
  • Remark if a c ? b c MOD e then a ? b MOD e.
    That is in modular arithmetic a cancellation rule
    for addition holds. On the other hand, if ac ? bc
    MOD e there is no general cancellation rule.
  • For example 14 ? 8 MOD 6 but 14 / 2 ? 1 (mod 6)
    while 8/2 ? 4 (mod 6).

13
Applications of Number Theory
  • Theorem 2 Let m, a, b, c be positive integers.
    Let ac ? bc (mod m) and gcd(c,m) 1 then a ? b
    (mod m). (the compound proposition p ? q ? r is
    TRUE where p ac ? bc (mod m), q gcd(c,m) 1
    and r a ? b (mod m) ).
  • Proof
  • p ? m ac bc c(a b) (m divides ac-bc)
  • q ? m (a b) (by Lemma 1).
  • But this means that a ? b (mod m) QED.
  • Observations
  • 1. If p is prime and p a1a2 . . . an then ?j
    such that p aj.2. Every integer n has a unique
    factorization into a product of primes.

14
Applications of Number Theory
  • Theorem 3 if a and b are relatively prime
    integers (b gt 1), then an inverse of a modulo b
    exists. Furthermore, this inverse is unique
    modulo b.
  • This is a direct consequence of the Extended GCD.
    Indeed if GCD(a,b) 1 then there are integers n1
    and n2 such that n1a n2b 1. Or n1a MOD b 1
    because n1b ? 0 (mod b). So n1 is an inverse of a
    modulo b.
  • In the example above gcd(57,23) 1 thus 57 has
    an inverse MOD 23.
  • We have gcd(57,23) 1 -2x57 5x23.
  • Thus 2 is an inverse of 57 MOD 23 and so is 2
    23 21. Indeed 5721 1197 2352 1.

15
Applications of Number Theory
  • Linear Congruences ax ? b (mod m)
  • Example Solve 35x ? 36 (mod 41)
  • Answer x 35.
  • Verify 3535 1225 4129 36
  • 3535 ? 36 (mod 41)
  • How do we solve it?
  • Recall a is the inverse of b (mod m) if ab ? 1
    (mod m)
  • How to solve ax ? b (mod m)?
  • Let y be the inverse of a (mod m).
  • x by (mod m)

16
Applications of Number Theory
  • Example solve 72x ? 47 (mod 133)
  • Step 1 find 72-1 (mod 133)
  • 133 721 61
  • 72 611 11
  • 61 115 6
  • 11 61 5
  • 6 51 1
  • gcd(133,72) 1.
  • 1 6 5 26 11 261 1111
  • 1361 1172 13133 2472 ( 1729 1728)
  • so 72-1 (mod 133) -24 or 133 24 109.
  • x 10947 (mod 133) 13338 69 (mod 133)
    69
  • Verify 6972 (mod 133) 4968 (mod 133)
  • 37133 47 (mod 133) 47.

17
Applications of Number Theory
  • Theorem 1 gcd(a,b) sa yb (This is called
    the Extended Euclidean Algorithm).
  • Lemma 1 a,b and c are positive integers.
    GCD(a,b) 1 (p) and a bc (q) then a c (r).
  • Theorem 2 Let m, a, b, c be positive integers.
    Let ac ? bc (mod m) and gcd(c,m) 1 then a ? b
    (mod m). (the compound proposition p ? q ? r is
    TRUE where p ac ? bc (mod m), q gcd(c,m) 1
    and r a ? b (mod m) ).
  • Theorem 3 if a and b are relatively prime
    integers (b gt 1), then an inverse of a modulo b
    exists. Furthermore, this inverse is unique
    modulo b.

18
Applications of Number Theory
  • Examplesgcd(35,78) a . 35 b . 78 29 . 35
    - 13 . 7878 2 . 35 835 4 . 8 38 2 .
    3 23 1 . 2 1gcd(35, 78) 11 3 -
    1.22 8 - 2 . 3 1 3 - 8 2 .3 3 . 3 - 83
    35 - 4 . 81 3 . 35 - 12 . 8 - 8 3 . 35 -
    13 .88 78 - 2 . 351 3 . 35 - 13 . 78 26 .
    35 29 . 35 - 13 . 78

19
Applications of Number Theory
  • Examples937 is an inverse of 13 modulo
    2436937 . 13 ? 1 (mod 2436) 937 . 13 12181
    5 . 2436 1

20
Applications of Number Theory
  • Examplesfind an inverse of 19 modulo
    141gcd(19, 141) 1, so there is an inverse of
    19 modulo 141.141 7 . 19 819 2 . 8
    38 2 .3 23 1 . 2 11 3 - 1 . 2 3
    - 8 2 . 3 - 8 3 . 31 -8 3 . (19 - 2 .
    8) -7 . 8 3. 191 -7. 141 49 . 19 3 .
    19 -7 . 141 52 . 19inverse of 19 (mod 141)
    52

21
Applications of Number Theory
  • Examplessolve the congruence 4x ? 5 (mod 9)x
    4 -1 . 5 an inverse of 4 (mod 9) is -2
    because 9 2. 4 1, which means 1 -2.4
    9x -2 . 5 -10 ? 8 (mod 9)

22
Applications of Number Theory
  • The Chinese remainder theorem
  • x ? a1 (mod m1) . . . x ? an (mod mn) has a
    unique solution modulo m m1 . . . mn if
    gcd(mi, mj) 1 for each pair.
  • Proof (constructive proof).
  • Let Mk m / mk GCD(mk, Mk) 1
  • Let yk be the inverse of Mk MOD mk. (ykMk ? 1
    (mod mk)).(theorem 3)
  • z (a1y1M1 a2y2M2 anynMn ) satisfies
    all congruences.
  • To see this note that ajyjMj MOD mi 0 if i
    ? j. Thus z mod mj ajyjMj MOD mj aj, because
    ykMk ? 1 (mod mk).
  • If we now choose x z, then z ? a1 (mod m1)
    . . . z ? an (mod mn).
  • Uniqueness (will be deferred to Chapter 4
    counting).

23
Applications of Number Theory
  • In a nut shell, every integer in the range 0, . .
    . , m-1 can be represented by the remainders.
    Suppose each mi is a 20 digit integer, i
    1,2,3,4,5. Then each integer n, of up to 100
    digits, can be represented by the five remainders
    n mod mi. Thus if our computer naturally
    accommodates 20 digit integers the Chinese
    remainder theorem allows us to store and actually
    develop arithmetic for much larger integers.
    The following Mathematic example illustrates how
    to use the Chinese remainder theorem
  • Note There are a few ways to calculate the
    inverse of a mod c in Maple. One is via the
    igcdex(a, b, s, t), another is via the imod
    function. imodab,c calculates (very quickly)
    ab mod c. In particular, a(-1) mod c returns
    the inverse of a mod c only when GCD(a,c) 1.

24
Applications of Number Theory
25
Applications of Number Theory
  • Problem Find an integer x such that
  • x mod 59 43
  • x mod 113 54
  • x mod 217 10
  • x mod 537 53
  • In simple words key1 is a multiple of
    113217537 which leaves remainder 1 when divided
    by 59. key2, key3, key4 are defined similarly.

26
Applications of Number Theory
27
Applications of Number Theory
28
Applications of Number Theory
  • The ancient Chinese, through many experiments and
    observations believed that p is prime if and only
    if
  • 2p-1 ? 1 (mod p)
  • Fermats little theorem
  • If p is prime then ap ? a (mod p) ? a gt 0
  • If p is prime and a is not divisible by p then
    ap-1 ? 1 (mod p) ? a gt 0
  • Comments
  • The ancient Chinese were almost right. Indeed if
    p is prime it must satisfy the Chinese
    hypothesis but unfortunately there are non primes
    that also satisfy this condition.
  • This theorem provides an efficient test for
    composite integers. Indeed if ap mod p ? a then p
    must be composite!

29
Applications of Number Theory
  • Some of The Mathematics used in Encryption.
  • Private key encryption both sender and receiver
    share the same secret key. For instance the key
    might be a 128 bit long binary sequence B. To
    encode break your message into 128 bit long
    chunks. For each chunk C send the 128 bit
    sequence B ? C. To decode, the receiver will
    retrieve B by calculating B ? (B ? C) C.
  • There are two problems with this scheme
  • Each pair of (sender, receiver) must have their
    own private keys.
  • The key must be somehow sent to the sender (or
    receiver).
  • To overcome this difficulty, Diffie and Hellman
    developed the idea of breaking each key into two
    parts a public part which every one can see and
    use and a private part which only the intended
    party will have. Thus, if a sender wishes to send
    a message to a receiver, hell use the receivers
    public key to encode the message. Only the person
    knowing the private key will be able to decode
    the message.
  • A mathematical implementation of this idea was
    developed by Rivest, Shamir and Adelman (3
    mathematicians at MIT).

30
Applications of Number Theory
  • The RSA (Rivest, Shamir, Adelman) encryption
  • Select two large primes p and q. Let m pq.
  • Select a number e such that gcd(e, (p-1)(q-1))
    1.
  • Tell the world that if anyone wants to send you
    a message R, send f(R) Re mod m. (if R gt m,
    then break R into chunks, each smaller than m,
    encrypt each chunk separately).
  • How do we decrypt?
  • Calculate d e-1 mod (p-1)(q-1).
  • Decrypt assume k Re mod m.
  • Calculate kd mod m. This is R.

31
Applications of Number Theory
  • Why?
  • kd mod m Red mod m Ra(p-1)(q-1) 1 mod m
  • R(R(p-1)(q-1))a mod m
  • R(p-1) mod p 1 (Fermat)
  • R(q-1) mod q 1 (Fermat)
  • Therefore R(p-1)(q-1) mod pq 1
  • And (R(p-1)(q-1))a mod pq 1
  • So R(R(p-1)(q-1))a mod pq R
  • Can anyone else retrieve R? Currently, the only
    way we know how to calculate R efficiently is by
    factoring m pq, retrieving p and q, calculate
    (p-1)(q-1). Calculate e-1, the inverse of e mod
    (p-1)(q-1).
  • As of today, no efficient factoring algorithm is
    known. It is a hotly researched subject!

32
RSA Encryption
  • Caesar cipher f(p) (p 3) mod
    26Decryption f-1(p) (p - 3) mod 26
  • RSA (Rivest /Shamir / Adleman) system for public
    key cryptography
  • encryption key n pq (p, q large primes)
  • exponent e relatively prime to (p-1)(q-1)

33
RSA Encryption
  • RSA encryption plaintext --gt integer M --gt
    integer C Me mod n
  • RSA decryptiond decryption key an inverse
    of e mod (p-1)(q-1)integer P Cd mod n
Write a Comment
User Comments (0)
About PowerShow.com