CSE115/ENGR160 Discrete Mathematics 03/17/11 - PowerPoint PPT Presentation

About This Presentation
Title:

CSE115/ENGR160 Discrete Mathematics 03/17/11

Description:

CSE115/ENGR160 Discrete Mathematics 03/17/11 Ming-Hsuan Yang UC Merced * 3.6 Integers and algorithms Base b expansion of n For instance, (245)8=2*82+4*8+5=165 ... – PowerPoint PPT presentation

Number of Views:69
Avg rating:3.0/5.0
Slides: 14
Provided by: CindaHee3
Category:

less

Transcript and Presenter's Notes

Title: CSE115/ENGR160 Discrete Mathematics 03/17/11


1
CSE115/ENGR160 Discrete Mathematics03/17/11
  • Ming-Hsuan Yang
  • UC Merced

2
3.6 Integers and algorithms
  • Base b expansion of n
  • For instance, (245)8282485165
  • Hexadecimal expansion of (2AE0B)16
  • (2AE0B)162164101631416201611175627
  • Constructing base b expansion

3
Base conversion
  • Constructing the base b expansion
  • nbq0a0, 0 a0ltb
  • The remainder a0, is the rightmost digit in the
    base b expansion of n
  • Next, divide q0 by b to obtain
  • q0bq1a1, 0a1ltb
  • We see a1 is the second digit from the right in
    the base b expansion of n
  • Continue this process, successively dividing the
    quotients by b, until the quotient is zero

4
Example
  • Find the octal base of (12345)10
  • First, 12345815431
  • Successively dividing quotients by 8 gives
  • 154381927
  • 1928240
  • 24830
  • 3803
  • (12345)10(30071)8

5
Modular expansion
  • Need to find bn mod m efficiently
  • Impractical to compute bn and then mod m
  • Instead, find binary expansion of n first, e.g.,
    n(ak-1 a1 a0)
  • To compute bn , first find the values of b, b2,
    , (b4)2b8,
  • Next multiple the where aj1

6
Example
  • To compute 311
  • 11(1011)2 ,So 31138 32 31 . First compute 329,
    and then 349281, and 38(34)2(81)26561, So
    311656193177147
  • The algorithm successively finds b mod m, b2 mod
    m, b4 mod m, , mod m, and multiply
    together those terms

7
Algorithm
  • procedure modular exponentiation (binteger,
    n(ak-1ak-2a1a0, , an)2, mpositive integer)
  • x 1
  • powerb mod m
  • for i0 to k-1
  • if ai 1 then x(x power) mod m
  • power(power power) mod m
  • end
  • x equals bn mod m
  • It uses O((log m)2 long n) bit operations

8
Example
  • Compute 3644 mod 645
  • First note that 644(1010000100)2
  • At the beginning, x1, power3 mod 645 3
  • i0, a00, x1, power32 mod 6459
  • i1, a10, x1, power92 mod 64581
  • i2, a21, x181 mod 64581, power812 mod
    6456561 mod 645111
  • i3, a30, x81, power1112 mod 64512321 mod
    64566
  • i4, a40, x81, power662 mod 6454356 mod
    645486
  • i5, a50, x81, power4862 mod 645236196 mod
    645126
  • i6, a60, x81, power1262 mod 64515876 mod
    645396
  • i7, a71, x(81396) mod 645471, power3962 mod
    645156816 mod 64581
  • i8, a80, x471, power812 mod 6456561mod
    645111
  • i9, a91, x(471111) mod 64536
  • 3644 mod 64536

9
Euclidean algorithm
  • Need more efficient prime factorization algorithm
  • Let abqr, where a, b, q, and r are integers.
    Then gcd(a,b)gcd(b,r)
  • Proof Suppose d divides both a and b. Recall if
    da and db, then da-bk for some integer k. It
    follows that d also divides a-bqr. Hence, any
    common division of a and b is also a common
    division of b and r
  • Suppose that d divides both b and r, then d also
    divides bqra. Hence, any common divisor of b
    and r is also common divisor of a and b
  • Consequently, gcd(a, b)gcd(b,r)

10
Euclidean algorithm
  • Suppose a and b are positive integers, ab. Let
    r0a and r1b, we successively apply the division
    algorithm
  • Hence, the gcd is the last nonzero remainder in
    the sequence of divisions

11
Example
  • Find the GCD of 414 and 662
  • 662414 1248
  • 414248 1166
  • 248166 182
  • 16682 2 2
  • 822 41
  • gcd(414,662)2

12
The Euclidean algorithm
  • procedure gcd(a, b positive integers)
  • x a
  • yb
  • while (y?0)
  • begin
  • rx mod y
  • xy
  • yr
  • end gcd(a,b)x
  • The time complexity is O(log b) (where a b)

13
3.7 RSA cryptosystem
  • Each individual has an encryption key consisting
    of a modulus npq, where p and q are large
    primes, say with 200 digits each, and an exponent
    e that is relatively prime to (p-1)(q-1) (i.e.,
    gcd(e, (p-1)(q-1))1)
  • To transform M Encryption CMe mod n,
    Decryption CdM (mod pq)
  • The product of these primes npq, with
    approximately 400 digits, cannot be factored in a
    reasonable length of time (the most efficient
    factorization methods known as of 2005 require
    billions of years to factor 400-digit integers)
Write a Comment
User Comments (0)
About PowerShow.com