liveBook · Manning

State matrix

As explained in Hacking Cryptography

A state matrix is a matrix representing the internal contents or successive states of a linear feedback shift register.

A state matrix records consecutive internal bits of a linear feedback shift register (LFSR). For an LFSR of length L, each row shifts the observed sequence by one position, exposing the recurrence that produces later bits. section 4.2.2

Equation 4.6
\[\begin{aligned} \begin{bmatrix} s_{3} \\ s_{4} \\ s_{5} \end{bmatrix} &= \begin{bmatrix} s_{0} & s_{1} & s_{2} \\ s_{1} & s_{2} & s_{3} \\ s_{2} & s_{3} & s_{4} \end{bmatrix} \begin{bmatrix} a_{0} \\ a_{1} \\ a_{2} \end{bmatrix} \notag\\ X &= SA \label{equation:lfsr-matrix} \end{aligned}\]

The matrix equation expresses the next L observed bits as the state matrix S multiplied by the tap vector A using Boolean arithmetic: multiplication is AND and addition is XOR. section 4.2.2

Recovering an LFSR from observed output follows these implementation steps:

  • Compute the tap vector with A = S⁻¹X; inversion failure indicates an unsuitable sequence or incorrect length. section 4.2.2

Known-plaintext recovery

Known plaintext reveals corresponding keystream bits by XORing plaintext with ciphertext. Trying candidate lengths, recovering taps, and decrypting the remainder can expose the original timestamped message.

How Hacking Cryptography covers it

How deep it goes
Explains matrix construction, Boolean inversion, error conditions, and Go implementation, stopping short of general matrix theory.
Examples
Uses consecutive LFSR states, observed keystream bits, Go recovery functions, and a timestamped known-plaintext test.
What it assumes
Assumes familiarity with LFSR output and XOR-based stream encryption while explaining matrix setup through concrete recurrence equations.
What you can do after
Diagnose and recover an LFSR by constructing, inverting, and solving its state matrix from observed bits.
How it connects
Connects LFSRs, coefficient matrices, Boolean matrices, stream ciphers, and known-plaintext attacks.

This explainer was generated by Manning's knowledge graph from the text of Hacking Cryptography. The section links point to the parts of the book it draws on.