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.

224 CHAPTER 11. KNAPSACK CIPHERS<br />

Knapsack Cipher Setup:<br />

1. Pick a set <strong>of</strong> super-increasing numbers: W 1 , W 2 , W 3 , W 4 , W 5 and P .<br />

2. Pick e < P with gcd(P, e) = 1. Use the Euclidean Algorithm to find<br />

d such that e × d ≡ 1 (mod P ).<br />

3. Compute the U’s: U i = e × W i %P .<br />

4. Make the U’s public. Keep the W ’s, e, d and P secret.<br />

To Encipher:<br />

1. Turn each letter <strong>of</strong> the message into its binary equivalent<br />

(a 1 , a 2 , a 3 , a 4 , a 5 ).<br />

2. Use the U’s to find the enciphered number M, <strong>of</strong> each letter:<br />

To Decipher:<br />

M = a 1 · U 1 + a 2 · U 2 + a 3 · U 3 + a 4 · U 4 + a 5 · U 5 .<br />

1. For each received cipher number M, compute N = (d · M)%P .<br />

2. Solve N = x 1 · W 1 + x 2 · W 2 + x 3 · W 3 + x 4 · W 4 + x 5 · W 5 for the x’s.<br />

3. Convert (x 1 , x 2 , x 3 , x 4 , x 5 ) into its letter equivalent.<br />

Examples:<br />

(1) Use the weights U 1 = 16, U 2 = 72, U 3 = 64, U 4 = 27 and U 5 = 93 to<br />

encipher swim.<br />

s = 10011 → 1 · U 1 + 0 · U 2 + 0 · U 3 + 1 · U 4 + 1 · U 5<br />

= 16 + 27 + 93 = 136.<br />

w = 10111 → 1 · U 1 + 0 · U 2 + 1 · U 3 + 1 · U 4 + 1 · U 5<br />

= 16 + 64 + 27 + 93 = 200.<br />

i = 01001 → 0 · U 1 + 1 · U 2 + 0 · U 3 + 0 · U 4 + 1 · U 5<br />

= 72 + 93 = 165.<br />

m = 01101 → 0 · U 1 + 1 · U 2 + 1 · U 3 + 0 · U 4 + 1 · U 5<br />

= 72 + 64 + 93 = 229.<br />

The ciphertext message is 136, 200, 165, 229.<br />

(2) Decipher 136, 200, 165, 229.<br />

Of course, we know the answer. But how could we find it if we didn’t<br />

already know it First, if we didn’t know e and P (the private key) but

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

Saved successfully!

Ooh no, something went wrong!