0

Let's say we have transformer(?) A = $\{0;1 \}$, B = $\{0;1\}$, $Q = \{q_0,q_1,q_2\}$, where A - plaintext alphabet, B - encryption alphabet, Q - the set of states. The functions of the rotor are described as:

$$q0 ◦ 0 → q0 \ \ \ q0 ∗ 0 → 0 \\ q0 ◦ 1 → q1 \ \ \ q0 ∗ 1 → 1 \\ q1 ◦ 0 → q2 \ \ \ q1 ∗ 0 → 2 \\ q1 ◦ 1 → q0 \ \ \ q1 ∗ 1 → 0 \\ q2 ◦ 0 → q1 \ \ \ q2 ∗ 0 → 1 \\ q2 ◦ 1 → q2 \ \ \ q2 ∗ 1 → 2$$

And the function which it executes is mod 3. Does it only work for determined length of plaintext? What algorithm is behind this scheme?

1 Answers1

2

This is not really a cryptographical question, but rather a (rather simple) question about a finite automata.

This is a state machine; you feed in the bits of the number $n$ you're modding, starting at the msbit (and starting at the state $q0$). After processing the number, if the state you end up in is $q0$, then $n \equiv 0 \pmod 3$, if you end up in $q1$, then $n \equiv 1 \pmod 3$, and if you end up n $q2$, then $n \equiv 2 \pmod 3$.

Does it only work for determined length of plaintext?

No, it'll work for any size integer.

What algorithm is behind this scheme?

Well, I suspect it's too simple to have a formal name. The property that always holds is that, after processing an intermediate integer $\hat{n}$ (which has the binary representation of the bits you're processed so far), if $\hat{n} \bmod 3 = i$, then you'll be in state $qi$.

Here's how that property is preserved: assume that property holds at some point. Then, when you process the next bit $j$ (which means that you will have processed the intermediate integer $2\hat{n} + j$, it will transition to state $q(2i+j \bmod 3)$ (you can verify this by manually going through the state transitions). And, since $2\hat{n} + j \equiv 2i+j \pmod 3$, this preserves the above invariance. Since we start with the property holding (that's why it's important we start at state $q0$), it holds no matter how many bits you process.

poncho
  • 147,019
  • 11
  • 229
  • 360