Correlation Attack on Filtered LFSRs (Belief Propagation)
- •
What it is
- •
A fast correlation attack treats a filtered LFSR’s output as a noisy version of a linear sequence. Parity constraints from the recurrence help correct those noisy observations and recover the internal state.
- •
- •
When to apply
- •
The filter has a biased linear approximation and enough observed keystream is available to decode a sequence satisfying the known recurrence.
- •
- •
Symbols and assumptions
- •
Destroyer’s output is z=1+F. The approximation is . Let be the corresponding exact linear sequence, and observe . All bit additions are XOR.
- •
- •
Math — step by step
- •
- Enumerating all 64 filter inputs gives F=ℓ on 48 inputs. Thus w=z+1 agrees with y on 3/4 of uniform local input tuples. Using z without complementing it would give only 1/4 agreement.
- •
- A linear combination of shifted copies of an LFSR sequence obeys the same recurrence. Hence . These sparse checks link noisy observations across time.
- •
- In characteristic 2, squaring cancels cross terms. Squaring the shift polynomial gives . Repeated squaring supplies checks at power-of-two spacings. These extra checks are related, not independent new measurements.
- •
- Under a crossover-probability 1/4 channel model, the initial log odds for y_t=0 over y_t=1 are . Positive means 0 is favored; negative means 1 is favored.
- •
- Belief propagation alternates parity-check messages and variable messages . Excluding the recipient prevents immediately feeding a message back to itself. Decide bit 1 when total log odds are negative.
- •
- From decoded y, solve 128 equations over GF(2), where h selects cells 16,32,127. The resulting 128×128 observation matrix has rank 128 for this recurrence, checked offline. This yields S at the first observed clock.
- •
- Reverse 256 warm-up clocks to recover the initial key state. Pack bits in the source’s most-significant-bit-first order. Regenerate all 20,000 observed bits; a parity-consistent or plausible-looking candidate is not sufficient.
- •
- •
Worked example
- •
One parity check is . Suppose independent incoming beliefs favor with probability 0.75 each. Their parity is 0 with probability , so the check sends odds favoring y0=0.
- •
If the direct observation w0=1, its channel odds favor y0=0 by only 1/3. Combining this one independent check gives odds , so y0=1 is still favored. Several consistent checks can eventually outweigh one noisy observation.
- •
- •
Checks and pitfalls
- •
Cycles in the parity graph and temporal dependence in the filter errors make this an approximate decoder; convergence is not guaranteed. Clip numerical messages before atanh, bound iterations, and verify against the actual nonlinear generator.
- •
Offline synthetic tests of the pasted final solver recovered and verified 2 of 3 fixed keys; one failed to converge. These are local reproducibility checks, not a live service replay or an estimate of the general success probability.
- •
With 2,500 zero plaintext bytes, XOR encryption exposes 20,000 keystream bits. The pasted service also imposes a 15-second connection timeout; precomputation and runtime need separate attention.
- •
- •
- •
Python
- •
import math, numpy as np def check_message(incoming): p = np.tanh(np.clip(incoming/2, -10, 10)) return np.array([2*np.arctanh(np.clip(np.prod(np.delete(p,j)), -.999999,.999999)) for j in range(len(p))]) def initial_llr(observed_w): # w agrees with the linear sequence with probability 3/4. return (1 - 2*np.asarray(observed_w, dtype=np.int8))*math.log(3)
- •