Question: 1. Run the following Python code that implements the product cipher example given above: import numpy as np #confusion-diffusion example using product cipher #plaintext message

1. Run the following Python code that implements the product cipher example given above:

import numpy as np

#confusion-diffusion example using product cipher

#plaintext message

m = np.matrix([1,0,0,1])

print('Plaintext =',m)

print()

#XOR part of product cipher

key1 = np.matrix([1,0,1,0])

c1=np.mod(m+key1,2)

print('Encrypt 1=',c1)

print()

#permutation part of product cipher

key2 = np.matrix([[0,0,1,0],[0,0,0,1],[1,0,0,0],[0,1,0,0]])

print('Key 2=',key2)

print()

#c2 is the ciphertext

c2=c1*key2

c2.astype(int)

c2=np.mod(c2,22)

print('Encrypt 2=',c2)

print()

#decrypt by by first inverting the pernutation

#and then inverting the exclusive XOR

Pinv=np.transpose(key2)

c1hat=c2*Pinv

c1hat.astype(int)

c1hat=np.mod(c1hat,2)

print()

print('P inverse=',Pinv)

print('Decrypt 2=',c1hat)

print()

m1hat=np.mod(c1hat+key1,2)

print('Decrypted ciphertext =',m1hat)

print()

a. Explain what the permutation matrix is doing to the bits in the plaintext.

b. Use the Python script productcipher.py to construct a table relating the ciphertext to every possible 4-bit plaintext message. Is it the case that all plaintext messages are scrambled? Is there any flaw in the system would allow an attacker to determine a key?

c. Choose a single 4-bit plaintext message and, by hand, work out each step in the encryption decryption process to show how the product cipher works.

d. Why is the product cipher a symmetric cipher?

e. How is the product cipher similar to the Vernam cipher discussed in Unit 1? How does it differ from the Vernam cipher?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!