Integers andAalgorithms - Discrete Mathematics - Lecture Slides, Slides of Discrete Mathematics

During the study of discrete mathematics, I found this course very informative and applicable.The main points in these lecture slides are:Integers and Algorithms, Hexadecimal Expansion, Constructing Base, Base Conversion, Successively Dividing Quotients, Octal Base, Modular Expansion, Modular Exponentiation, Bit Operations, Euclidean Algorithm, Sequence of Divisions

Typology: Slides

2012/2013

Uploaded on 04/27/2013

aslesha
aslesha 🇮🇳

4.4

(14)

160 documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSE115/ENGR160 Discrete Mathematics
03/17/11
1
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Integers andAalgorithms - Discrete Mathematics - Lecture Slides and more Slides Discrete Mathematics in PDF only on Docsity!

CSE115/ENGR160 Discrete Mathematics

3.6 Integers and algorithms

  • Base b expansion of n
  • For instance, (245) 8 =28^2 +48+5=
  • Hexadecimal expansion of (2AE0B)

(2AE0B) 16 =216^4 +1016^3 +1416^2 +016+11=

  • Constructing base b expansion

Example

Modular expansion

• Need to find b n^ mod m efficiently

• Impractical to compute b n^ and then mod m

• Instead, find binary expansion of n first, e.g.,

n=(a k-1 … a 1 a 0 )

• To compute b n^ , first find the values of b, b 2 , …,

(b^4 ) 2 =b^8 , …

• Next multiple the where a j =

5

b n^ = bak^ −^1 ⋅^2 k −^1 ++ a^1 ⋅^2 + a^0 = bak −^1 ⋅^2 k −^1 bak −^2 ⋅^2 k −^2 ba^1 ⋅^2 ba^0

j b^2

Algorithm

  • procedure modular exponentiation ( b:integer, n=(a (^) k-1a (^) k-2a 1 a 0 , …, a (^) n ) 2 , m:positive integer) x := 1 power:=b mod m for i:=0 to k- if a (^) i =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

Example

Euclidean algorithm

  • Suppose a and b are positive integers, a≥b. Let r 0 =a

and r 1 =b, we successively apply the division

algorithm

  • Hence, the gcd is the last nonzero remainder in the

sequence of divisions

10

n n n n

n n

n n n

n n n n n n

r r r r

a b r r r r r r

r rq

r r q r r r

r rq r r r

r rq r r r

= = =

= = = =

=

= + ≤ <

= + ≤ <

= + ≤ <

− −

− − − −

gcd( , ) gcd( , 0 )

gcd( , ) gcd( , ) gcd( , ) gcd( , )

, 0

...

, 0

, 0

1

0 1 1 2 2 1

1

2 1 1 1

1 2 2 3 3 2

0 1 1 2 2 1

Example

  • • Find the octal base of (12345)
  • • First, 12345=8*1543+
    • 1543=8*192+ • Successively dividing quotients by 8 gives
    • 192=8*24+
    • 24=8*3+
    • 3=8*0+
  • • (12345) 10 =(30071)
  • • Compute 3 644 mod
    • – First note that 644=(1010000100)
    • – At the beginning, x=1, power=3 mod 645 =
    • – i=0, a 0 =0, x=1, power=3^2 mod 645=
    • – i=1, a 1 =0, x=1, power=9^2 mod 645=
    • – i=2, a 2 =1, x=1*81 mod 645=81, power=81^2 mod 645=6561 mod 645=
    • – i=3, a 3 =0, x=81, power=111^2 mod 645=12321 mod 645=
    • – i=4, a 4 =0, x=81, power=66^2 mod 645=4356 mod 645=
    • – i=5, a 5 =0, x=81, power=486^2 mod 645=236196 mod 645=
    • – i=6, a 6 =0, x=81, power=126^2 mod 645=15876 mod 645=
    • – i=7, a 7 =1, x=(81*396) mod 645=471, power=396^2 mod 645=156816 mod 645=
    • – i=8, a 8 =0, x=471, power=81^2 mod 645=6561mod 645=
    • – i=9, a 9 =1, x=(471*111) mod 645=
  • • 3 644 mod 645=
  • • Find the GCD of 414 and
    • 662=414 ∙ 1+
    • 414=248 ∙ 1+
    • 248=166 ∙ 1+
    • 166=82 ∙ 2 +
    • 82=2 ∙
    • gcd(414,662)=

3.7 RSA cryptosystem

  • Each individual has an encryption key consisting of a modulus n=pq, 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: C=Me^ mod n, Decryption: C d^ =M (mod pq)
  • The product of these primes n=pq, 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)