06.01.2015 Views

Cryptology - Unofficial St. Mary's College of California Web Site

Cryptology - Unofficial St. Mary's College of California Web Site

Cryptology - Unofficial St. Mary's College of California Web Site

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

222 CHAPTER 11. KNAPSACK CIPHERS<br />

77 = (3) + 6 + 13 + 55. Yes to 3.<br />

77 = 3 + 6 + 13 + 55. Done. Found a total that works.<br />

(3) Same weights. Demand is for 81.<br />

81 = (81). Yes to 55.<br />

81 = (26) + 55. No to 27. Yes to 13.<br />

81 = (13) + 13 + 55. Yes to 6.<br />

81 = (7) + 6 + 13 + 55. Yes to 3.<br />

81 = (4) + 3 + 6 + 13 + 55. Yes to 2.<br />

81 = (2) + 2 + 3 + 6 + 13 + 55.<br />

Done. We didn’t find a total that was correct, and since we can only use<br />

each weight once, this means there is no solution.<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

In general, when the numbers or weights are super-increasing, the greedy<br />

method will find a solution when there is one, and will indicate that no solution<br />

is possible when it is impossible.<br />

Example: Weights 3, 7, 12, 24, 49, 104, and 215. Which <strong>of</strong> the totals 298,<br />

421, 358 and 311 can be found 3 ⋄<br />

Thus, if the weights are super-increasing the knapsack problem is very easy.<br />

If they are not, it can be very very difficult. Next we transform the easy knapsack<br />

problem into (apparently) a hard one.<br />

Example: Consider the five weights W 1 = 3, W 2 = 7, W 3 = 12, W 4 = 24<br />

and W 5 = 49. These are in super-increasing order and so form the weights <strong>of</strong><br />

an easy knapsack problem. For example, can these weights produce the total <strong>of</strong><br />

80 Yes: 80 = 49 + 24 + 7.<br />

Now let e = 39 and P = 101. e is our “enciphering” multiplier. If we<br />

multiply the W ’s by e modulo P we obtain new weights, U 1 through U 5 :<br />

W 1 × e = 3 × 39 ≡ 16 ≡ U 1 (mod 101)<br />

W 2 × e = 7 × 39 ≡ 71 ≡ U 2 (mod 101)<br />

W 3 × e = 12 × 39 ≡ 64 ≡ U 3 (mod 101)<br />

W 4 × e = 24 × 39 ≡ 27 ≡ U 4 (mod 101)<br />

W 5 × e = 49 × 39 ≡ 93 ≡ U 5 (mod 101)<br />

The weights 16, 71, 64, 27 and 93 are not in super-increasing order! Can the<br />

total 90 (= (80 × 39)%101) be produced from them 4 We have succeeded in<br />

3 Only 298 and 358 are possible.<br />

4 Yes, but only modulo 101: 90 = (93 + 27 + 71)%101.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!