On the Subject of 3×3 Yellow Ciphers

This yellow is not mellow, as it will try to give you 2 threes and X you.

This module contains 3 screens, a keyboard, 2 arrows, and a submit button that displays the current page you’re on.

Pressing the left or right arrow takes the defuser to the previous or next page, wrapping around the last page. There are 3 pages.

To disarm the module, decrypt a word using the following steps. Once you have the decrypted word, type it in using the keyboard. When you start typing, the screens go blank and the bottom screen will show what you are typing.

To clear your input, click one of the arrows.
Once you are satisfied with your input, press the button labeled “SUB” to submit your answer. An incorrect submission will cause a strike but NOT reset the module.

When the instructions say to modulo a value by N, repeatedly add or subtract N to that value to keep the value within the range of 0 to (N - 1).

Step 1: 3×3 Matrix Inverse Calculation

Depending on what screen(s) are shown in white, you will need to calculate the inverse of exactly one of the matrices. In the order of top to bottom on pages 2 and 3, the displayed numbers correspond to 2 separate matrices, with elements labeled a-i in reading order. On page 1, the middle and bottom screens display the determinants of the matrices from pages 2 and 3 respectively.
You do NOT need to calculate the determinant of a 3×3 matrix.

If on page 2, all the screens are white, or the middle screen of page 1 is white, the inverse of the second matrix MUST be calculated. Otherwise, the inverse of the first matrix MUST be calculated.

Using the determinant of the matrix needed to be inversed, modulo 26, as E, calculate for D. Instructions to calculate for D can be found on page 4.

Then calculate the following 9 values in THIS order:

  1. (e * i) - (f * h)
  2. (f * g) - (d * i)
  3. (d * h) - (e * g)
  4. (c * h) - (b * i)
  5. (a * i) - (c * g)
  6. (b * g) - (a * h)
  7. (b * f) - (c * e)
  8. (c * d) - (a * f)
  9. (a * e) - (b * d)

Multiply those 9 values by D, and modulo all of them by 26. Write the results of this top to bottom, left to right to obtain the inverse matrix.
An example to obtain the inverse matrix can be found on page 3.

For the next step, if you have the inverse matrix of the matrix mentioned on the module via page numbers, use the THAT inverse matrix instead to decrypt. Otherwise, use the matrix displayed on that page.

Step 2: 3×3 Hill Cipher, The Actual Calculation

Using the matrices, start by splitting the top display of page 1 into sets of 3 letters. Convert these sets of 3 letters into their alphabetic positions, with Z equating to 0.

If the last digit of the serial number is greater than 4, calculate using the matrix on page 3, then the matrix on page 2. Otherwise, calculate using the matrix on page 2, then the matrix on page 3.

For each set, to use the 3×3 matrix, multiply the values of the first column in that matrix by the first value of the set of 3. Repeat this with the second column and the second value of the set of 3, and again with the third column and the third value of the set of 3. Add the multiplied values, row by row to get 3 new values. Modulo each of the 3 new values by 26 and then if this is the last matrix calculated, convert these back to their alphabetic counterparts, with 0 equating to Z.

Example: Multiplying With A 3×3 Matrix

Obtained Matrix:

1177
161916
02417

Set of 3 values: 12, 1, 2

12*1 + 1*17 + 2*7 = 43
12*16 + 1*19 + 2*16 = 243
12*0 + 1*24 + 2*17 = 58

New set of 3 values, after modulo 26: 17, 9, 6

Example: Calculating The Inverse Matrix

Obtained Matrix:

192415
21115
9214

Determinant of Matrix: -3625

E = -3625 mod 26 = 15; D = 7

(1 * 14) - (15 * 2) = -16, (-16 * 7) mod 26 = 18
(15 * 9) - (21 * 14) = -159, (-159 * 7) mod 26 = 5
(21 * 2) - (1 * 9) = 33, (33 * 7) mod 26 = 23
(15 * 2) - (24 * 14) = -306, (-306 * 7) mod 26 = 16
(19 * 14) - (15 * 9) = 131, (131 * 7) mod 26 = 7
(24 * 9) - (19 * 2) = 178, (178 * 7) mod 26 = 24
(24 * 15) - (15 * 1) = 345, (345 * 7) mod 26 = 23
(15 * 21) - (19 * 15) = 30, (30 * 7) mod 26 = 2
(19 * 1) - (24 * 21) = -485, (-485 * 7) mod 26 = 11

Inverse Matrix:

181623
572
232411

Determining D - Logic Way

  1. Set up 7 variables: A, B, Q, R, T1, T2, T3.
  2. Set A equal to 26.
  3. Set B equal to E.
  4. Q is equal to A / B, rounded down.
  5. R is equal to A modulo B.
  6. Set T1 equal to 0.
  7. Set T2 equal to 1.
  8. T3 is equal to T1 - (T2 * Q).
  9. Set A equal to B.
  10. Set B equal to R.
  11. Q is equal to A / B, rounded down.
  12. R is equal to A modulo B.
  13. Set T1 equal to T2.
  14. Set T2 equal to T3.
  15. T3 is equal to T1 - (T2 * Q).
  16. Repeat steps 9 - 15 until R is equal to 0, stopping at step 12.
  17. Your D is equal to T3 mod 26.

Determining D - Brute Force Way

  1. Find I in this equation: ((I * 26) + 1) modulo E = 0
  2. D is equal to: ((I * 26) + 1) / E
    • A. This can be used as well: (D * E) modulo 26 = 1

Determining D - Look Up Way

Doing inverse calculations can take a while, so here’s this table to help
(You’re going to need this... Right?):

E357911151719212325
D921153197231151725