ics141-lecture17-NumApps

ics141-lecture17-NumApps - 17-1ICS 141 Discrete Mathematics...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 17-1ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiICS141: Discrete Mathematics for Computer Science IDepartment of Information and Computer SciencesUniversity of HawaiiStephen Y. Itoga17-2ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiLecture 17Chapter 3. The Fundamentals3.6 Integers and Algorithms3.7 Applications of Number Theory17-3ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiSome material in these slides were taken/adapted from the slides made by Prof. Michael P. Frank and Prof. Jonathan L. Gross which are provided through the publisher of “Discrete Mathematics and Its Applications” written by Kenneth H. Rosen.Some slides were done by Prof. Baek17-4ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiMultiplication of Binary Numbersab= a(b·2+ b1·21+ ··· + bn-1·2n-1)= a(b·20 ) + a(b1·21 ) + ··· + a(bn-1·2n-1)proceduremultiply(an−1…a, bn−1…b: binary representations of positive integers a,b)product:= 0fori:= 0 to n−1ifbi= 1 thenproduct:= add(an−1…a0···0, product)returnproductiextra 0-bits appended after the digits of aitimes17-5ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiBinary Division with Remainderprocedurediv-mod(a∈Z,d∈Z+) {Quotient & rem. of a/d}q := r := |a|whiler≥dbeginr := r – dq := q + 1endifa <and r then {ais a negative integer}beginr := d – rq := –(q + 1)end{q= adivd(quotient), r= amodd(remainder)}17-6ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiModular ExponentiationProblem:Given large integers b(base), n(exponent), and m(modulus), efficiently compute bnmod m.Note that bnitself may be completely infeasible to compute and store directly.E.g. if nis a 1,000-bit number, then bnitself will have far more digitsthan there are atoms in the universe!Yet, this is a type of calculation that is commonly required in modern cryptographic 17-7ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiNote that:We can compute bto various powers of 2 by repeated squaring.Then multiply them into the partial product, or not, depending on whether the corresponding nibit is 1.Crucially, we can do the modmoperations as we go along, because of the various identity laws of modular arithmetic.– All the numbers stay small.22112211)()()(222222nnnnnnnbbbbbkkkkkkkk×××==--------⋅++⋅+⋅Algorithm ConceptThe binary expansion of n= b1= b……17-8ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiModular ExponentiationproceduremodularExponentiation(b: integer,n = (nk−1…n)2, m: positive integers)x:= 1 {result will be accumulated here}b2i:= bmodm{ mod m; i=0 initially}fori:= 0 to k−1 {go thru all kbits of n}ifni= 1 thenx:= (x·b2i) modmb2i:= (b2i·b2i) modmreturnx{xequals bnmodm}ib2)()(222221iiiibbbb⋅==⋅+17-9...
View Full Document

This note was uploaded on 09/12/2008 for the course ICS 141 taught by Professor Idk during the Fall '08 term at Hawaii.

Page1 / 25

ics141-lecture17-NumApps - 17-1ICS 141 Discrete Mathematics...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online