Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

MATHEMATICS Maan Patel

INVESTIGATION
An investigation on cryptography including matrices
Introduction

Cryptography is a form of coding to protect information and communications so that only the
intended people can read it. It is also used in computer science to secure information using
mathematical concepts. Algorithms, which are rule-based calculations, are used to change messages
in a way so that they are difficult to decode.

Matrix addition can often be decoded easily so more sophisticated methods have been developed.
Matrix multiplication has been implemented which is much harder to decode.

The aim of this investigation is to encode and decode messages with the help of matrices and
algorithms. This will be done by completing addition matrices so encode a message and then
decoding the codes by subtracting the matrices with the code matrix. As for matrix multiplication,
the message will be decoded by multiplying with the inverse code matrix. This will be completed by
using the table below to turn a message into coded form by writing a message in numbers with its
corresponding letter. The table can also be used to convert numbers into letters. The code is then
formed into groups of 4 which are then converted into 2×2 matrices, which is then encoded and
then decoded using a code matrix.

A B C D E F G H I J K L M
1 2 3 4 5 6 7 8 9 10 11 12 13
N O P Q R S T U V W X Y Z
14 15 16 17 18 19 20 21 22 23 24 25 0
Figure 1: coding values

Each letter in the alphabet is assigned an integer which is then used to form matrices to create
algorithms in order to make a code. The message, SEND MONEY PLEASE, can be broken down into
groups of four letters. Each group is then encoded with the help of matrices.

SEND/MONE/YPLE/ASEE – An extra letter is repeated at the end to finish a group of four. It is called
the dummy letter which has no real meaning but is used when the last group of a message has less
than four letters. The numbers are then placed in a 2×2 matrix and afterwards the matrix is added by
a certain encryption matrix.

For example, ‘SEND’ would be encrypted as, [ 1914 54 ]+[ 132 75]=[ 2127 129 ] .

The matrix must be written in Modulo 26 (mod 26), meaning if numbers in a matrix are not between
0 and 25, they must be added or subtracted by multiples of 26. Since the resultant matrix contains
the number 27, it must be subtracted by 26.

[ 1927 59] ≡ [27−26


19 5
4]
, Modulo 26 (mod 26)¿ [191 54 ]
.

The remaining 3 groups are calculated as following:

MONE -
[ 1314 155 ]+[132 75]=[ 1527 2310] , (mod26) =
15
[ 27−26 22
10 ] =[
15 22
1 10 ]
YPLE -
[ 2512 165 ]+[ 132 75]=[ 2725 2310]
, (mod26) = [ 27−26
25
23 1 23
10 ] [25 10 ]
=

ASEE -
[ 15 195 ]+[ 132 75 ]=[183 2610] , (mod26) = [ 183 26−26
10 ] =[
3 0
19 10 ]

Mathematical investigation & analysis

Question 1
In order to confirm that the code for SEND MONEY PLEASE is correct, subtraction of the matrices is
to be calculated in order to decipher the coded message. The original message was added by the
code matrix to achieve the coded message and by subtracting by the code matrix, the original
message will be retrieved. The resultant modulus 26 matrices of the addition of the code are then

subtracted by the matrix [ 132 75] , then each resultant matrix is written in modulus 26.

SEND - [ 211 129 ]−[ 132 75 ]=[−12


19 5 ≡
]4 [−12+19 26 54] (mod 26)=[1419 54] (mod 26)
MONE - [ 151 2210]−[132 75]=[−1213 15 ≡ 13
]5 [−12+26 15 ( mod 26 ) = 13 15 (mod 26)
5] [ 14 5 ]
YPLE - [ 251 2310]−[132 75]=[−112 165 ] ≡ [−1+26
12
16 ( mod 26 )= 25 16 (mod 26)
5] [ 12 5 ]
ASEE - [ 183 100 ]−[132 75]=[ 15 −75 ] ≡ [15 −7+26
5 ]
( mod 26 )=[ 1 19 ] (mod 26)
5 5
This calculation creates the message code, 19.5.14.4.13.15.14.5.25.16.12.5.1.19.5.5. Using Figure 1,
the code is deciphered, and the message created is, SEND MONEY PLEASE. It is proven that the
original message is obtained from the addition of the message code.

Question 2
The code given to decode is,
21.12.1.9.22.15.18.25.20.22.2.21.21.1.2.25.10.12.0.20.23.1.21.20.8.1.21.10.15.2.5.23.3.6.12.4
Every four numbers, in order, are converted into a matrix. The numbers produce the following
matrices:

[ 211 129 ][ 2218 1525][ 202 2221][ 212 251 ][100 1220][ 2321 201 ][ 218 101 ][ 155 232 ][ 123 64 ]
With the coding matrix [ 132 75] , the groups of matrices are subtracted with this coding matrix in

order to decipher the message.

[ 211 12
9
2 7
][ ][ ][
− =
19 5
13 5 −12 4

19 5
−12+ 26 4
( mod 26 )= 19
14 ] [ 54](mod 26)
[ 2218 15 2 7 20 8 20 8
25 ] [13 5 ] [ 5 20 ] [ 5 20 ]
− = ≡ ( mod 26 )

[ 202 22 2 7 18 15 18
21 ] [ 13 5 ] [−11 16 ] [−11+26 16 ]
− = ≡
15
( mod 26 ) =[ 18 15 ] (mod 26)
15 16

[ 212 1
25 ] −[
2 7
] =[
13 5 −11 20
19 −6
] ≡[
19
−11+26
−6+26
20 ] ( mod 26 )=[ 19 20 ] (mod 26)
15 20

[ 100 12
20 ] −[
2 7
] =[
8 5
] ≡[
13 5 −13 15 −13+ 26 15
8 5
] ( mod 26 )=[ 8 5 ] (mod 26)
13 15

[ 2321 1
20 ] −[
2 7
13 5 ] =[
21 −6
8 15 ] ≡[
21 −6+26
8 15 ] ( mod 26 )=[ 21 20 ] (mod 26)
8 15

[ 218 1 2 7 6 −6
10 ] [ 13 5 ] [ 8 5 ] [ 8
− = ≡
6 −6+20
5 ]
( mod 26 )=[ 6 20 ](mod 26)
8 5

[ 155 2 2 7 13 −5
23 ] [13 5 ] [−8 18 ] [−8+26
− = ≡
13 −5+26
18 ]
( mod 26 )=[ 13 21 ] ( mod 26)
18 18

[ 123 6 2 7 1 −1 1
4 ] [ 13 5 ] [ −1 −1 ] [−1+ 26 −1+ 26 ]
− = ≡
−1+ 26
( mod 26 ) =[ 1 25 ] (mod 26)
25 25
Once decoded with the steps above, the numbers decoded from the matrices are as following:

19.5.14.4.20.8.5.20.18.15.15.16.19.20.15.20.8.5.13.15.21.20.8.15.6.20.8.5.13.21.18.18.1.25.25.25.

SEND/THET/ROOP/STOT/HEMO/UTHO/FTHE/MURR/AYYY

There are dummy numbers added to the end of the code to finish a group of four numbers. Once the
code is deciphered with dummy letters removed, the message reads, SEND THE TROOPS TO THE
MOUTH OF THE MURRAY.

Question 3
The task for this aspect of the investigation is to create a matrix addition code and then give it to a
peer for them to solve. The message which will be encoded is DEV IS HANDSOME. The coding matrix

is [ 35 124 ] . First, the matrix addition code is to be created by dividing the message into groups of

four and then using figure 1 to create matrices.

DEVI/SHAN/DSOM/EEEE (3 dummy letters, ‘E’) can be written as [ 224 59][191 148 ][ 154 1913][55 55]
The coding matrix is then added to each of these matrices and then the resultant matrix if
transformed into a modulo 26 matrix.

DEVI - [ 224 59]+[ 35 124 ]=[277 1713] ≡ [ 27−26 7 17


13 ]
( mod 26 )=[ 7 17 ](mod 26)
1 13

SHAN – [ 191 148 ]+[ 35 124 ]=[ 126 2018] ≡ [ 126 2018](mod 26)
DSOM - [ 154 1913]+[ 35 124 ]=[207 3117] ≡ [ 207 31−2617 ] ( mod 26 ) =[ 7 5 ](mod 26)
20 17

EEEE - [ 55 55]+[ 35 124 ]=[108 179 ] ≡ [ 108 179 ] (mod 26)


The final code for the message, DEV IS HANDSOME, is, 7. 17. 1. 13. 12. 20. 6. 18. 7. 5. 20. 17. 8. 17.
10. 9. This code was then given to a peer to solve. The steps to decoding the code were taken by the

peer and the code matrices were subtracted by the code matrix [ 35 124 ] , to gather the original code

and then the message was deciphered.

[ 71 1713 ]−[ 35 124 ]=[−44 59] ≡ [−4+4 26 59 ] ( mod 26)=[ 224 59] ( mod 26 )
[ 126 2018]−[ 35 124 ]=[ 91 148 ] ≡ [91 148 ]( mod 26)
[ 207 175 ]−[35 124 ]=[ 154 −713 ] ≡ [154 −7+26 13 ]
( mod 26 )=[ 4 19 ] ( mod 26 )
15 13

[ 108 179 ]−[35 124 ]=[ 55 55] ≡ [ 55 55 ] ( mod 26)


As shown in the subtraction matrices, the numbers decoded are 4. 5. 22. 9. 9. 8. 1. 14. 4. 19. 15. 13.
5. 5. 5. 5. These numbers produce the message with dummy letters removed, DEV IS HANDSOME,
which is correct and supports the original message.

Question 4
Part A

The form of SEND MONEY PLEASE is to be found with the use of matrix multiplication. The provided

decoding matrix is [ 21 32]


.

SEND –
[ 1914 54 ]× [ 21 32]=[ 4332 6750] ≡ [ 43−26
32−26
67−( 2× 26) ( mod 26 )= 17 15 ( mod 26 )
50−26 ] [ 6 24 ]
MONE - [ 1314 155 ] × [21 32]=[ 4133 6952]≡ [ 33−26
41−26 69−(2× 26) ( mod 26 )= 15 17 ( mod 26 )
52−(2× 26) ] [7 0]
YPLE -

[ 2512 165 ]× [ 21 32]=[ 6629 10746 ] ≡ [ 66−(2 ×26) 107−(4 × 26) ] ( mod 26 )=[ 14 3 ] ( mod 26 )
29−26 46−26 3 20

ASEE -
[ 15 195 ] × [ 21 32]=[2115 4125] ≡ [ 2115 1525] ( mod 26 )
Hence, the coded form of SEND MONEY PLEASE is, 17. 15. 6. 24. 15. 17. 7. 0. 14. 4. 3. 20. 21. 15. 15.
25.

Part B

For this message to be deciphered, the inverse of the coded matrix is to be calculated. This is
because the original message was multiplied by the code matrix to achieve the coded message and
by multiplying by the inverse code matrix, the original message will be retrieved.

- ad−bc=( 2× 2 )−( 3 ×1 )
- ad−bc=1
−1 1 2 −3 2 −3
- A =
1 −1 2[ =
][
−1 2 ]
The inverse of the coded matrix is [−12 −32 ] . To prove that the inverse matrix is required for the

message to be deciphered, the encrypted form of SEND MONEY PLEASE will be decoded as shown
below:

[ 176 15
24 ][
×
2 −3
−1 2
=
19 −21
][
−12 30

19 −21+26
][
−12+26 30−26
( mod 26 )= 19
]
14 [ 54] ( mod 26 )
[ 157 17 2
0 ] [−1
×
−3
=
13 −11

13 −11+26
2 ] [−12 −21 ] [ −12+ 26 −21+ 26 ]
( mod 26 )=[ 13 15 ] ( mod 26 )
14 5

[ 143 3 × 2
20 ] [−1
−3 = 25 −36 ≡ 25
2 ] [ −14 31 ] [ −14+ 26
−36+(2 ×26) ( mod 26 )= 25 16 ( mod 26 )
31−26 ] [ 12 5 ]
[ 2115 15 × 2
25 ] [−1
−3 = 27 −33 ≡ 27−26 −33+(2 ×26) ( mod 26 )= 1 19 ( mod 26 )
2 ] [5 5 ] [ 5 5 ] [5 5 ]
With the multiplication of inverse matrices, the code can be deciphered and with these calculations,
it is evident that the code spells SEND MONEY PLEASE.

Part C

A code matrix is to be created where ad−bc=1 and this is completed with the help of the matrix,

[ ac bd ] . So, numbers are substituted into the equation, ad−bc=1, and solved with trial and error.

Let a=3 , b=5 ,c=1, d=2

The numbers are substituted into the equation, ( 3 ×2 ¿−(5 ×1)=1When the numbers are solved,
the numbers are suitable to use as the difference of ad and bc equals to 1.
The code matrix which is formed is, [ 31 52] .

The message, I AM VERY STRESSED, is to be decoded with multiplication matrices and the decoding

matrix, [ 31 52] . The first step is to convert the message into groups of four and creating matrices,

which are then multiplied by the code matrix [ 31 52] , and converted into coded form.

IAMV/ERYS/TRES/SEDD – The message is divided into groups of four. An extra ‘D’ is added to the end
of the last group as a dummy number as the group did not have enough numbers to make a
complete group of four.

IAMV -

[ 139 221 ] × [ 31 52]=[2861 47 ≡ 28−26


109 ][ 47−26
61−(2 ×26) 109−(4 × 26)
( mod 26 )= 2 21 ( mod 26 )
9 5 ] [ ]
ERYS -

[ 255 1819] × [ 31 52]=[ 3394 61 ≡ 33−26


163 ][ 61−(2× 26) ( mod 26 ) ≡ 7 9 ( mod 26 )
94−(3 ×26) 163−(6× 26) 16 7 ] [ ]
TRES -

[ 205 1819] × [ 31 52]=[3478 136 ≡ 78−(2 ×26) 136−(5× 26) ( mod 26 )= 0 6 ( mod 26 )
63 ][ 34−26 63−(2× 26) 8 11 ] [ ]
SEDD -

[ 194 54] × [ 31 52]=[6216 105 ≡ 62−( 2× 26) 105−(4 × 26) ( mod 26 )= 10 1 ( mod 26 )
28 ][ 16 28−26 16 2 ] [ ]
The coded message from the multiplication is, 1.21.9. 5. 7. 9. 16. 7. 0. 6. 8. 11. 10. 1. 16. 2.

The coded message is then decoded by multiplying each modulo matrix by the inverse decode
1 2 −5
= 2 −5
matrix. Since ad−bc=1, the inverse code matrix would be A =
−1
[
1 −1 3 −1 3][ ]
Each matrix is now multiplied to the inverse code matrix to decode the message. If the numbers in
the result matrix are not between 0 and 26, the number is added or subtracted by multiples of 26
until it falls within the range.

[ 29 215 ] × [−12 −5 = −17 53 ≡ −17+ 26 53−(2 ×26) ( mod 26 ) = 9 1 ( mod 26 )


3 ][13 −30 ][
13 −30+(2 ×26) ]13 22 [ ]
[ 167 79] ×[−12 −5 = 5 −8 ≡ 5
3 ] [ 25 −59 ] [ −8+ 26
25 −59+(3 × 26) ] ( mod 26 )=[ 5 18 ] ( mod 26 )
25 19

[ 08 116 ] × [−12 −5 −6 18
]3 =[ 5 −7] ≡ [−6+265
18
−7+26 ] ( mod 26 )=[ 20 18 ] ( mod 26 )
5 19

[ 1016 12] × [−12 −5 = 19 −47 ≡ 19


3 ] [ ] −47+(2 ×26) ( mod 26 ) = 19 5 ( mod 26 )
30 −74 [ 30−26 −74+(3 ×26) ] [ 4 4]
Once decoded, the numbers are 9. 1. 13. 22. 5. 18. 25. 19. 20. 18. 5. 19. 19. 5. 4. 4.

With the help of figure 1, the numbers can be decoded into I AM VERY STRESSED. This supports and
confirms the original message.

Part D

When the coding matrix satisfies, ad−bc ≠ 1, the numbers can be fractions when calculations are
made, which makes it extremely hard to decode. The inverse matrix will also contain fractions within
the matrix causing problems to solve/decode the message. The matrix should be changed or
converted so that, ad−bc=1. This can be completed by multiplying the matrix with another certain
matrix which will convert the fraction numbers into integers. When ad−bc=−1, the code matrix is
changed completely, and the code will not be able to be deciphered as the inverse matrix will not be
correct.

For example, if the code matrix is intended to be [ 21 32] , a message will be able to be coded and

when decoding, the inverse matrix is [−12 −32 ] as ad−bc=1.

- ad−bc=( 2× 2 )−( 3 ×1 )
- ad−bc=1
−1 1 2 −3 2 −3
- A =
1 −1 2[ = ][
−1 2 ]
If ad−bc=−1, the inverse matrix will be as following:

−1 −2 3
-
−1
A = [
1 1 −2 ]
If this inverse code matrix is used to decipher the message, the original worded message will not be
retrieved as it has no relation with the intended code matrix.

Part E

A coded message will be created with multiplication matrices and then will be passed onto a peer to
decode. Numbers 1 to 26 are given to alphabets A to Z and on this occasion, ‘space’ and ‘?’ are
assigned numbers to make it even more difficult to decode.

A B C D E F G H I J K L M N
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Spac ?
O P Q R S T U V W X Y Z e 0
15 16 17 18 19 20 21 22 23 24 25 26 27
Figure 2: code of values with additional values.

The message that will be converted into a coded message will be ARE YOU OK?

The message is divided into groups of 4 and then the number matrices are made, each assigned to a
group.
ARE(SPACE)/YOU(SPACE)/OK?? (An extra ‘?’ is added since it is a dummy letter to complete the
group of 4). According to Figure 2, the code can be written as 1. 18. 5. 27. 25. 15. 21. 27. 15. 11. 0. 0.

This code is transformed into matrices and then multiplied by the code matrix [ 31 52] .

ARE(SPACE) - [ 15 1827 ]× [ 31 52]=[ 2142 4179] ≡[ 42−28


21 41−28 ( mod 28 )= 21 13 ( mod 28 )
79−(2× 28) ] [14 23]
YOU(SPACE) -

[ 2521 1527 ]× [ 31 52]=[ 9090 155 ≡ 90−(3 × 28) 155−(5 ×28) ( mod 28 )=[ 6 15 ] ( mod 28 )
159 [ 90−(3 × 28) 159−(5 ×28) ]
] 6 19

OK?? -
[ 150 110 ] × [ 31 52]=[ 560 970 ] ≡ [56−(2×
0
28) 97−(3 ×28) ( mod 28 ) = 0 13 ( mod 28 )
0 ] [0 0 ]
The resultant matrices were added or subtracted by 28 since there are 28 values in Figure 2, making
it modulo 28. The final coded message is 21. 13. 14. 23. 6. 15. 6. 19. 0. 13. 0. 0.

This coded message was given to a friend for them to decode. Figure 2 and the code matrix was also
provided to him. They distributed the code into groups of 4 and then converted into matrices which
will then be multiplied by the inverse of the code matrix to decode the message.

First, the inverse of the code matrix was calculated with ad−bc.

1 2 −5
= 2 −5
-detA =( 3 ×2 )−( 5 ×1 ) A−1= [
1 −1 3 ][
−1 3 ]
-detA =1

The inverse matrix is then used to multiply each matrix in order to decode the message.

[ 2114 1323] × [−12 −53 ]=[ 295 −66


−1 ] ≡ [ 29−28 −66+(3 ×28) ] ( mod 28 )=[ 1 18 ] ( mod 28 )
5 −1+ 28 5 27

[ 66 1519 ]× [−12 −53 ]=[−3 15


] ≡[
−7 27 −7+28 27
−3+28 15
] ( mod 28 )=[ 25 15 ] ( mod 28 )
21 27

[ 00 130 ]× [−12 −53 ]=[−130 390 ] ≡ [−13+28 0


39−28
0 ] ( mod 28 )=[ 15 11 ] ( mod 28 )
0 0
Once the matrices are multiplied, the numbers are written in order and the code calculated is 1.18.
5. 27. 25. 15. 21. 27. 15. 11. 0. 0. When this code is deciphered, the message obtained is ARE YOU
OK? This is the intended message meaning Ben has decoded the message successfully.

Conclusion

This investigation was completed successfully by encoding messages with the help of Figure 1 and
Figure 2, along with matrices. The message SEND MONEY PLEASE was encoded and then decoded to
find the coded message 19.5.14.4.13.15.14.5.25.16.12.5.1.19.5.5. Then the coded message was
arranged into groups of four, which was then converted into matrices added by a code matrix. Then
to decode the coded message, the code matrix was subtracted from the matrices which was then
converted into a letter message. With the messages where the code matrix was multiplied, the
inverse matrix of the code matrix was post multiplied to the code to obtain the original worded
message.

Another problem solved in the investigation was the decoding of a coded message provided along
with a decoding matrix. The numbers were arranged into groups of four in order to convert them
into 2×2 matrices. The matrices were then subtracted by the decoding matrix in order to calculate
the code which was then to be deciphered and achieve the message which was hidden in the code.

A peer was given a coded message and a decoding matrix to calculate and decipher the hidden
message. The message was first coded by adding the decoding matrix to the coded message
matrices. The code was then provided to a peer to calculate. They separated the code into groups of
four, which they converted into matrices. The matrices were then subtracted by the same decoding
matrix which was used to code the original message. The code they calculated was then deciphered
to obtain the original message, DEV IS HANDSOME.

The final problem solved in this investigation was to figure out if multiplication could be used in
order to encode and decode messages. With the results gathered in the investigation, it is proven
that matrix multiplication is reliable to use for cryptography. They are more reliable to use as they
are more difficult to decode due to the extensive calculations required. A decoding matrix is to be
first multiplied to the original message code to encode it. The coded message is then converted into
matrices, which are then multiplied by the inverse of the decoding matrix to decode and decipher
the message.

An assumption made in this investigation was that the numerical values on the decoding values was
the same as the integer values provided. Different integer values would change the coded message
as calculations would be performed with different numbers. The message can be successfully coded
and decoded if the decoding table is consistent for all calculations. Another assumption in this
investigation was the encryption table given as the values would have to be the same as the values
which were used to encrypt the code. If not, the code will not be able to be deciphered since
different values would have been used. It is also assumed that the message was only made of letters
for the whole investigation excluding Question 4-part E. Except for the last part of the investigation,
spaces had to be added to the message manually and make guesses regarding where the spaces
were to work out the message. In part E, the process of guessing was eliminated, and the exact
message was calculated as the encryption table included the symbols and spaces in the message,
making it easier to calculate the exact message. This also means there is little room for error in
working out the message.

A limitation in this investigation includes only using 2×2 matrices when a range of other matrices
could have been used. Groups of 4 were arranged into these matrices whereas, different numbers of
groups could have been formed. For example, groups of 9 could have been arranged into 3×3
matrices. This would be extremely useful for longer messages as it would take more calculations
along with time to decode the message. The code matrix must stay consistent with the matrix
configuration in order to successfully use different matrix orders. Another limitation in this
experiment includes the use of symbols in the encryption table. There could have been symbols such
as ‘commas’ or ‘full stops’ in the messages but the encryption table did not include these values,
meaning the final message will not have contained these symbols and the exact message will not be
retrieved.
Cryptography has been proven to be extremely useful from this investigation as messages can be
encoded into numbers which is useful to hide messages. This experiment could be extended to have
a more sophisticated encryption table as there were no values for symbols for most of this
investigation. This will allow the message to be more accurate.

You might also like