hw9sol - Computer Science 340 Reasoning about Computation...

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

View Full Document Right Arrow Icon
Computer Science 340 Reasoning about Computation Homework 9 Due at the beginning of class on Wednesday, November 28, 2007 Problem 1 Consider the following computational problem: Given N, a, b, x, y , where N 1 is prime, a, b, x, y are integers between 1 and N - 1, compute a x b y (mod N ). 1. Describe an algorithm that takes at most 4 k + C multiplications, where k = log N and C is a positive constant. 2. Design an algorithm that uses at most 2 k + C 0 multiplications, for some constant C 0 . Solution sketch: The naive algorithm computes a x (mod N ) then b y (mod N ) and then multiplies them modulo N . This takes roughly 4 k multiplications, using repeated exponentiation. To halve that number, let x k - 1 ··· x 1 x 0 and y k - 1 ··· y 1 y 0 be the binary representations of x and y . Set c = ab (mod N ) and z = 1. Then repeat for i = k - 1 down to 0: if ( x i , y i ) = (1 , 1) then set z to z 2 .c (mod N ); if ( x i , y i ) = (1 , 0) then set z to z 2 .a (mod N ); if ( x i , y
Background image of page 1

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

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

Page1 / 2

hw9sol - Computer Science 340 Reasoning about Computation...

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

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