# Toy Tetragraph hash

Im trying to understand how TTH works, but have a question.

Let's take this example: ABCDEFGHIJKLMNOP

We have

A B C D
E F G H
I J K L
M N O P


Then we add each column mod 26 and add the result to the running total, mod 26, in this example, the running total is (24,2,6,10)

Round 2: Using the matrix from round 1, rotate the first row left by 1, second row left by 2, third row left by 3, and reverse the order of the fourth row. In our example.

B C D A
G H E F
L I J K
P O N M


Now , add each column mod 26 and the result to the running total. The new running total is (5,7,9.11).

This running total is now the input into the first round of the compression function for the next block of text. After the final block is processed, convert the final running total to letters. For example. If the message is ABCDEFGHIJKLMNOP, then the hash is FHJI.

So, my question is how to we use the hash FHJI for the next block of data if it exist?

Assume our data was ABCDEFGHIJKLMNOP QRSTUVWXYZABCDEF.

How will I use the runing total produced by first block of data with another, following block?

## 2 Answers

My reading of the definition of Toy Tetragraph Hash is that "The running total" is 4 integers modulo 26, initially at (0,0,0,0). It is modified by processing each 16-letter message block. Then in a final step, it is converted to letters, forming the hash.

Thus in the example, the running total after processing ABCDEFGHIJKLMNOP is (5,7,9,11); it is used when processing the second block QRSTUVWXYZABCDEF, and becomes (15,21,1,7) after the first round for that block, and (8,12,16,20) after the second round. In the end it is converted to the hash IMQU.

Your "FHJI" is really FHJL. The totals produced by the first block (24, 2, 6, 10) were add mod 26'd to the totals produced by the add mod 26 of all 4 columns. Example. add mod 26 column one (B, G, L, P) = 7, take that 7 and add mod 26 (7 and 24) = 5, which is the first number of the next HASH FHJL (5, 7, 9, 11) and is also your running total. Let's say you add another 4x4 block for Round 3. You would then do another round of shifting and reversing and add mod 26 the first column from Round 2 (B, G, L, P) and the new (x, x , x, x) from Round 3 shifting, for an n result. (REPEAT FOR THE NEXT THREE COLUMNS) This will give you a new (n, n, n, n). You will then add mod 26 the new (n, n, n, n) to your running total/HASH(FHJL) (5, 7, 9, 11). This result is the new running total/HASH (n, n, n, n). Repeat as you add blocks.