0% found this document useful (0 votes)
5 views6 pages

MATH220_Tutorial1_sols

The document contains solutions to various problems related to discrete mathematics, particularly focusing on cryptography and voting mechanisms. It discusses the decryption of different ciphers, the use of an affine cipher for voting, and the Playfair cipher for message encryption and decryption. Additionally, it includes mathematical proofs and calculations related to prime numbers and composite integers.

Uploaded by

cameroncassie410
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views6 pages

MATH220_Tutorial1_sols

The document contains solutions to various problems related to discrete mathematics, particularly focusing on cryptography and voting mechanisms. It discusses the decryption of different ciphers, the use of an affine cipher for voting, and the Playfair cipher for message encryption and decryption. Additionally, it includes mathematical proofs and calculations related to prime numbers and composite integers.

Uploaded by

cameroncassie410
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

MATH220-25S1 Discrete Mathematics

Tutorial 1

1. (a) Eve finds the ciphertext bob which was encrypted using a Caesar cipher. Explain
why the plaintext was not eve.
(b) Eve finds the ciphertext ale which was encrypted using an affine cipher. Explain
why the plaintext was not bob.
(c) Eve finds the ciphertext mvwzxmswder which was encrypted using a Vigenère cipher
with key key. Decrypt the message.
Solution:

(a) If e is encrypted to b, then the Caesar cipher is x 7→ x−3, so v would be encrypted


to s.
(b) An affine cipher is a substitution cipher; since bob contains twice the letter b, the
ciphertext should contain the same letter on the first and third position.
(c) The easiest way is to use the Vigenère tableau: in the row of k, look for m, and
see that is lies in the column of c. Similarly, in the row of e, look for v, and see
that is lies in the column of r, etc.. we find that the plaintext is cryptoisfun.

2. The encryption function of an affine cipher in Z42 is given by x → 5x + 3. Determine


k, l in the decryption function d(y) = ky + l.
Solution:
The decryption function is given by d(y) = 5−1 (y − 3). To find the inverse of 5 in Z42
we use the Extended Euclidean algorithm:

42 = 7 × 5 + 7
7=1×5+2
5=2×2+1

So 1 = 5 − 2(7 − 5) = 3 × 5 − 2 × 7 = 3 × 5 − 2(42 − 7 × 5) = 17 × 5 − 2 × 42. We


conclude that 5−1 = 17 in Z42 . So d(y) = 17y − 3 ∗ 17 = 17y + 33. Hence, k = 17,
l = 33.
3. You try to use the affine cipher in Z26 given by x → 13x + 3. What problems might
you encounter? Give an example of a message that would be hard to decipher even if
you had the encryption key.
Solution:
Since 13 is not invertible in Z26 , this is not a subsitution cipher. In fact all symbols
get mapped to either 3 or 16, depending on whether they are even or odd. If the
26 numbers correspond to letters A . . . Z, then the messages ‘I LOVE MATHS’ and ‘I
HATE MATHS’ would both be encrypted as 3 16 3 16 3 16 3 3 16. Of course in this case,
it would be easy to decipher because everyone loves maths.
MATH220-25S1 Tutorial 1 2

4. Voting with numbers. Suppose a 15-person committee has to vote to approve the
Prime Minister’s executive order. Members prefer to keep their votes anonymous. The
following is a method for voting in which everyone votes Yes, No, or Abstain, but simul-
taneously ensures each vote is kept secret.

The commitee Chair takes a blank piece of paper, writes a large number, say 5963,
on it, and passes it on to the next member. In turn, that member adds 16 for Yes, 1 for
No, and 0 for Abstain to this number, and writes the new number on a blank piece of
paper and passes it on to the next member to repeat. This process continues until the
Chair receives a number from the last member on the committee, at which time they
add 16 for Yes, 1 for No, or 0 for Abstain.

(a) Suppose the final sum is 6096. How many Yes votes, No votes, and Abstain votes
were cast?
(b) Why count a yes vote as 16? Would 15 work too?
(c) Determine all possible positive integers for which a yes vote with that value does
not work (that is, if a yes vote has that value, then the Chair cannot uniquely
determine the number of votes for yes/no/abstained).

Solution:

(a) First calculate 6096-5963=133, which is the total number added by committee
members. We see that
133 = 8 · 16 + 5,
so there were 8 votes Yes, 5 votes No, and the remaining 2 votes abstained.
(b) This doesn’t work because we cannot see the difference between 1 yes vote and 14
abstained (which totals 15) or 15 no’s.
(c) Suppose that a Yes vote is given by the integer a. If there are x yes votes and
y no votes (and 15 − x − y abstainances), the total number added is ax + y.
We need to make sure that we can retrieve x and y from ax + y. Suppose that
ax + y = ax0 + y 0 , then
a(x − x0 ) = y 0 − y.
We need to find the values of a such that this equation only has the solution
x = x0 , y = y 0 . Now y − y 0 lies in between −15 and 15, and a(x − x0 ) = y 0 − y
says that y − y 0 is a multiple of a. So if we choose a > 15, then there certainly
cannot be a solution different from (x, y) = (x0 , y 0 ).
Is there any choice smaller than 16 that still works? No! It is clear that we can
never distinguish between 1 yes vote with value a and zero no votes and zero yes
votes and a no votes.

5. (a) Write down the 5 × 5-array for the Playfair cipher using the key mathematics
(b) Use this Playfair cipher to encrypt the plaintext saturday.
MATH220-25S1 Tutorial 1 3

(c) What happens if you encrypt the ciphertext obtained in (b)? Will this phenomenon
always occur? Explain.
Solution:

(a)
m a t h e
i/j c s b d
f g k l n
o p q r u
v w x y z
(b) We split as sa tu rd ay. sa defines the rectangle with corners c and t. Similarly,
we find that tu becomes eq, rd becomes ub and ay becomes hw. So we find the
ciphertext ctequbhw.
(c) When we encrypt the ciphertext ctequbhw we find the plaintext saturday back.
This makes sense because if we take two letters from different rows and columns,
it defines an involution, that is, if we encrypt these two letters and then encrypt
again, we find the original letters back. However, this does not hold true when we
encrypt two letters from the same row: for example, the word math is encrypted
as athe, and if we encrypt athe we find them.

6. Find gcd(299, 247) and all integer solutions of the equation 299m + 247n = 13.
Solution:
Using Euclid’s Algorithm,

299 = 1 × 247 + 52
247 = 4 × 52 + 39
52 = 1 × 39 + 13
39 = 3 × 13 + 0

So gcd(299, 247) = 13. Working backwards,

13 = 52 − 39
= 52 − (247 − 4 × 52) = 5 × 52 − 247
= 5 × (299 − 247) − 247
= 5 × 299 − 6 × 247

So one solution of the equation 299m + 247n = 13 is

m = 5, n = −6.

The equation is the same as 23m + 19n = 1 (dividing by the gcd). So the general
solution is
m = 5 + 19t, n = −6 − 23t,
where t is an integer.
MATH220-25S1 Tutorial 1 4

7. Show that the difference of two consecutive cubes is never divisible by 3 or 5.


Solution:
Now (n + 1)3 − n3 = 3(n2 + n) + 1 ≡ 1 mod 3. Therefore (n + 1)3 − n3 is never divisible
by 3.
Working in Z5 , we have

n ≡ 0 1 2 3 4
n2 ≡ 0 1 4 4 1
2
n +n ≡ 0 2 1 2 0
3(n2 + n) ≡ 0 1 3 1 0
3(n2 + n) + 1 ≡ 1 2 4 2 1

Therefore (n + 1)3 − n3 = 3(n2 + n) + 1 is never congruent to 0 mod 5, that is, it is


never divisible by 5.

8. Find all integers n (positive or negative) such that n2 − n is prime.


Solution:
Note that n2 − n = n(n − 1) and so, as one of n and n − 1 is even, n2 − n is even.
Since 2 is the only even prime, this implies that n2 − n = 2, that is (n + 1)(n − 2) = 0,
so n = −1 or n = 2.

9. If n > 1, show that the n consecutive integers

(n + 1)! + 2, (n + 1)! + 3, . . . , (n + 1)! + (n + 1)

are all composite. (This shows that there are arbitrarily large gaps between primes.)
Solution:
If j is an integer between 1 and n + 1, then, since

(n + 1)! = (n + 1) · n · (n − 1) · · · j · · · 1,

j divides (n + 1)! and therefore j divides (n + 1)! + j. So (n + 1)! + j has a non-trivial


divisor if 2 ≤ j ≤ n + 1 and therefore (n + 1)! + j is composite.

10. (A good question for when you have time to spare!) You are a well-known
cryptanalyst and you have just received the following memo.

Memo:
To: Hut 6d, Bletchley Park
From: Col. W.T. Tutte1 , Military Attache
This message was received by an intercept station in Scotland. The frequency and
format indicate that it is a most urgent message from one of our agents who landed a
1
A pioneer of modern-day graph theory, find out about W.T. Tutte and his cipher breaking during the
second world war.
MATH220-25S1 Tutorial 1 5

week ago in Norway. His controllers have been unable to read it. Although it clearly uses
his backup cipher, the Playfair, the keys assigned to him do not work. We cannot reach
him before his normal scheduled transmission in three weeks, so we urgently request that
you attempt to decrypt this and let us know the contents. In case it helps, he is carrying
materials to assist a previously dropped team in their work regarding the Norsk Hydro
facility at Rjukan. His recognition code might appear in the message: It is “beware ice
weasels”. If he is operating under duress, he will not use it and instead will include the
phrase “red penguin frenzy”. He will use “stop” between sentences and “end” at the
end.

Received message: FVLYP IPGLU LYPQH FFSDE MDHEV OKNCB GEPSM FNCKY GSSBU
PURKI UFOHH QZRYS FUHEL CXSAP BUOVA EIFYL UPWED SWGFK ZBFGE GUIHL UPQEU
FPUBD KBOVK YFTZP QUMRB OLUHN NHNRW MAQPA BCFIP SMHKB UHEDO VHEMO SGIFB
CFKVU GBBGK CXXXX

It is vital that this message be broken as soon as possible.

Hints
The Playfair cipher has two characteristic properties which are of great use in deciphering.

• No letter can be enciphered to itself.


• If ab is enciphered to XY, then ba is enciphered to YX.

Look first at “beware ice weasels”. It may be segmented as


-b ew ar ei ce we as el s- or as
be wa re ic ew ea se ls
In the second case, it might appear either

• at the beginning of the message or


• at the end, in which case it will appear as
st op be wa re ic ew ea se ls en dx
or
• inside the message, in which case it must be in the form
st op be wa re ic ew ea se ls st op

(a) Check which (if any) of these four possibilities can occur.
(b) Consider the possible segmentations of the phrase “red penguin frenzy” and, as
before, find any allowable ones. Use the information you now have, to construct
as much of the Playfair square as you can.
(c) Find the original key phrase and decipher the whole message.
MATH220-25S1 Tutorial 1 6

Solution:
The key phrase is
a r c h i m e d e s and the message reads

most urgent stop all members of glider team killed stop


in contact with norsk hydro informant stop red penguin frenzy stop
do not send follow up team untill i give coordinates and time for safe
landing zone end

You might also like