[关闭]
@vourdalak 2019-05-03T12:45:46.000000Z 字数 1549 阅读 625

CS 161 Homework 4

CS161


R-11.2

Use the divide-and-conquer algorithm, from Section 11.2, to compute 10110011·10111010 in binary. Show your work.

Use Karatsuba multiplication.









(calculate from the same way, divide-and-conquer)

R-24.5

Show the execution of method FastExponentiation(5, 12, 13) by constructing a table similar to Table 24.6.

p 12 6 3 1 0
r 1 12 8 5 1

R-24.6

Write a nonrecursive version of Algorithm ExtendedEuclidGCD.

  1. def ExtendedEuclidGCD(a,b):
  2. if b == 0:
  3. return (a, 1, 0)
  4. x1 = 0
  5. x2 = 1
  6. y1 = 1
  7. y2 = 0
  8. while b > 0:
  9. q = a // b
  10. r = a - q * b
  11. x = x2 - q * x1
  12. y = y2 - q * y1
  13. a = b
  14. b = r
  15. x2 = x1
  16. x1 = x
  17. y2 = y1
  18. y1 = y
  19. d = a
  20. x = x2
  21. y = y2
  22. return (d,x,y)

Output:

  1. print(ExtendedEuclidGCD(175,20))
  2. > (5, -1, 9)

C-24.8

Suppose the primes p and q used in the RSA cryptosystem, to define , are in the range [ ]. Explain how you can efficiently factor using this information.

The size of the range is . For each composite number n, there is a range of to be checked. For each n, we calculate and , and then look for prime numbers in the range. Once we have the list of possible prime numbers we multiply them pair by pair to see if the product is n.

As n becomes larger and larger (especially RSA mostly uses very large integers), the range to be searched in ()will become quite large. And determining prime numbers in this range one by one can be difficult too. For a number as large as a normal RSA, I don't think it will be possible to use such range information to factor the number.

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注