This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 171ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiICS141: Discrete Mathematics for Computer Science IDepartment of Information and Computer SciencesUniversity of HawaiiStephen Y. Itoga172ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiLecture 17Chapter 3. The Fundamentals3.6 Integers and Algorithms3.7 Applications of Number Theory173ICS 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. Baek174ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiMultiplication of Binary Numbersab= a(b·2+ b1·21+ ··· + bn1·2n1)= a(b·20 ) + a(b1·21 ) + ··· + a(bn1·2n1)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 0bits appended after the digits of aitimes175ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiBinary Division with Remainderproceduredivmod(a∈Z,d∈Z+) {Quotient & rem. of a/d}q := r := awhiler≥dbeginr := r – dq := q + 1endifa <and r then {ais a negative integer}beginr := d – rq := –(q + 1)end{q= adivd(quotient), r= amodd(remainder)}176ICS 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,000bit 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 177ICS 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……178ICS 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⋅==⋅+179...
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.
 Fall '08
 IDK

Click to edit the document details