## Math 5410 Homework Assignment #4

Click on the problem number to see the answer

1. Prove that all the irreducible binary polynomials of degree 5 are primitive.

2. What is the period of the Linear Feedback Shift Register which has the characteristic polynomial

x5 + x4 + x2 + x + 1?

3. Find the linear equivalence of a Feedback Shift Register which produces the period 7 sequence that starts 1 0 1 0 0 1 1 ... . Construct a Linear Feedback Shift Register which will produce this sequence and indicate the starting state that gives the sequence.

4. Suppose we are told that the plaintext

featherbrain

yields the ciphertext

RUPOTENTOTCE

where the Hill Cipher is used (but m is not specified). Determine the encryption matrix.

5. Decrypt the following message which has been encrypted using a method we have seen.

```NSRVK DKSIW JWYCE CEGKC EBDKN QYSJU LXZOL XPSUV UTFBS OINPC RREUY
ONUFK HKZDD OJPQZ CKJIE NAFJD WBUSJ URCLC JCEPC OKTVF AFPYX GKKYZ
V.
```

The period of a binary irreducible polynomial of degree n is a divisor of 2n - 1. In this case, a divisor of 25 - 1 = 31. If the period of a binary irreducible polynomial of degree n equals 2n - 1, then it is a primitive polynomial. Since 31 is prime, having only 1 and itself as divisors, the period of any binary irreducible polynomial of degree 5 (which can not be 1) must be 31, and so, the polynomial must be primitive.

We first determine if the polynomial is irreducible (does not factor). Since the degree of the polynomial is 5, we only have to check for factors of degrees 1, 2, 3 or 4. But if there were a factor of degree 3 or 4, the other factor would have degree 1 or 2. So, we need only look for factors of degree 1 or 2. The possible degree 1 factors are x and x+1, but x clearly doesn't divide our polynomial and x+1 doesn't either because 1 is not a root of our polynomial. The only quadratic factor we have to check is x2 + x + 1 (the other quadratics all have linear factors themselves, and we have already ruled out linear factors). Just doing the long division, we see that this is not a factor either. Thus, our polynomial is irreducible. The period of an irreducible polynomial must divide the integer 2degree of polynomial -1, in our case 25 -1 = 31. As 31 is prime, the only possible periods are 1 and 31. The period of a polynomial is the smallest integer m, so that the polynomial divides xm +1. Since, our polynomial is of degree 5, it can not divide x1 + 1, so 1 can not be its period. Therefore, it has period 31 and so is a primitive polynomial (its period is the largest that it can be).

The linear equivalence of a sequence is the degree of the smallest characteristic polynomial that will produce that sequence. From the class notes, since S(7) = 1 + x2 + x5 + x6 (corresponding to a single repetition of the repeating sequence 1010011....), the linear equivalence is the degree of the polynomial m*(x) = (1+x7)/gcd(S(7), 1+x7). We use the Euclidean Algorithm to determine the gcd of these two polynomials:

```x7 + 1 = (x+1)(x6 + x5 + x2 + 1) + (x5 + x3 + x2 + x)
x6 + x5 + x2 + 1 = (x+1)(x5 + x3 + x2 + x) + (x4 + x2 + x + 1)
x5 + x3 + x2 + x = x(x4 + x2 + x + 1) + 0
```
So, gcd(S(7), 1+x7) = x4 + x2 + x + 1, and therefore, m*(x) = x3 + x + 1. The linear equivalence of this sequence is 3.

The LFSR which produces this sequence has characteristic polynomial m(x) (i.e., the reciprocal of m*(x) above) which is x3 + x2 + 1. If we want the sequence to start with 101 ... then 101 must be the starting state of the LFSR having only 3 stages.

Start with the choice m=1 to see if this works. This can be easily dismissed because the letter E is encrypted to both U and E, so this is a contradiction.

Next consider m=2. In this case we get the requirement that e(FE) = RU and e(AT) = PO. These can be written as the matrix equation

```  [ 5  4 ]     [ 17 20 ]
[ 0 19 ] K = [ 15 14 ]
```
This means that
```               -1
[ 5  4 ]  [ 17 20 ]   [ 17 16 ]
K =  [ 0 19 ]  [ 15 14 ] = [  9 24 ]
```
This can't be the solution however because we need to have e(HE) = TE, or
[ 7 4 ] K = [ 19 4 ],
which does not work.

We next try m=3, in which case we get the equations e(FEA) = RUP, e(THE) = OTE, and e(RBR) = NTO. These lead to the matrix equation

```   [  5  4  0 ]     [ 17 20 15 ]
[ 19  7  4 ] K = [ 14 19  4 ] mod 26
[ 17  1 19 ]     [ 13 19 14 ]
```
If you solve this system for K, you get
```      [ 21  22  13 ]
K = [ 17  23   7 ].
[ 17  16  18 ]
```
To see that this is correct, we need to calculate [ 0 8 13 ] K = [19 2 4].

After counting letter frequencies, calculate the Index of Coincidence which turns out to be 0.0409. This value clearly indicates that some type of polyalphabetic cipher is used. Quickly running through the Autokey keys, shows that this is not an Autokey cipher. We will assume that it is a Vigenere. The keylength is calculated to be 8.526, and there is a pair of trigrams SJU located 56 letters apart. Given the short length of the message (only 111 letters long), statistical variation will make the computational procedures inaccurate. Reasonable keylengths which are divisors of 56 are 4, 7 and 8. Trying 7 and 8 does not lead to fruitful results. Trying a keylength of 4, we write the cryptogram in 4 columns and examine the frequencies of the letters in each column. With such a small amount of data, high frequency letters may not appear with typical high frequencies, but low frequency letters will of course remain low frequency. So, rather than attempting to find the supposedly high frequency "e", it will be better to search for a low frequency section corresponding to "vwxyz", i.e., a section of the frequency distribution of length 5 having many zero's and a few small numbers. In column 1, we find such a section 0, 1, 0, 1, 0 starting at r. In column 2; 0, 1, 0, 0, 0 starting at j, in column 3; 0, 0, 0, 1, 0 starting at m and in column 4; 1, 0, 0, 0, 0 starting at g. If these are really the correspondents to "vwxyz" then the letter that follows them will correspond to "a" and thus will be the keyword letter. These observations lead to the keyword WORK, and the decrypted message:

Real optimism consists in marching undauntedly forward to a higher goal with as full an understanding as possible of every obstacle.