Linear feedback shift registers are predictable #
An n-bit linear feedback shift register (LFSR) with a set of tap positions in {0, …, n - 1}
holds a state (b_{n-1}, …, b_0). Each clock cycle outputs b_0, computes the feedback bit, the
exclusive or of the bits at the tap positions, and shifts the register to
(b, b_{n-1}, …, b_1) Boneh and Shoup, Section 3.8, p. 75.
Here the register is a list of bits starting with b_0, and the tap set is a tap mask: a list
taps in which position v is a tap when taps[v] = true. Mask bits beyond the register length
are ignored. The feedback bit is the inner product Cslib.BitString.listDot taps state.
Any n consecutive output bits are the state of the register at the time the first of them was
output, so they determine all later output bits. In particular output bit i ≥ n is the feedback
bit of the n bits before it, and the predictor that computes it wins Attack Game 3.2 at every
position i ≥ n with probability 1. The statements hold for every seed, including the
all-zero seed that [BS23] excludes.
Main definitions #
Cslib.Crypto.PRG.LFSR.step: one clock cycle.Cslib.Crypto.PRG.LFSR.output: the firstℓoutput bits.Cslib.Crypto.PRG.LFSR.generator: the register as a generator fromnbits toℓbits.Cslib.Crypto.PRG.LFSR.predictor: the predictor for output biti.
Main results #
Cslib.Crypto.PRG.LFSR.drop_output_eq_output_take_drop:nconsecutive output bits determine all later output bits.Cslib.Crypto.PRG.LFSR.getD_output_add: the linear recurrence of the output.Cslib.Crypto.PRG.LFSR.listDot_drop_take_generator: for every seed, output biti ≥ nis the feedback bit of thenbits before it.Cslib.Crypto.PRG.LFSR.predictionExperiment_predictor: the predictor is always right.Cslib.Crypto.PRG.LFSR.advantage_predictionTest_predictor: the test built from the predictor has advantage1 / 2in Attack Game 3.1.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Section 3.8, p. 75.
One clock cycle of a linear feedback shift register
Boneh and Shoup, Section 3.8, p. 75. The register is listed from the bit b_0
that is output next, and position v is a tap when taps[v] = true. The feedback bit
listDot taps state enters at the high end and b_0 leaves.
A single LFSR is predictable Boneh and Shoup, Section 3.8, p. 75: any
n consecutive output bits of an n-bit register determine all later output bits, which are the
output of the register started on those n bits. When fewer than n bits remain after position
t, the statement says only that a register clocked as often as it is long outputs its state.
The generator and Attack Game 3.2 #
A single LFSR is predictable Boneh and Shoup, Section 3.8, p. 75, in
Attack Game 3.2: for every position i ≥ n, the predictor guesses output bit i of an n-bit
register with probability 1.