galois.FLFSR.step(steps: int = 1)

Produces the next steps output symbols.

Parameters:
steps: int = 1

The direction and number of output symbols to produce. The default is 1. If negative, the Fibonacci LFSR will step backwards.

Returns:

An array of output symbols of type field with size abs(steps).

Examples

Step the Fibonacci LFSR one output at a time. Notice the first $$n$$ outputs of a Fibonacci LFSR are its state reversed.

In [1]: c = galois.primitive_poly(7, 4)

In [2]: lfsr = galois.FLFSR(c.reverse(), state=[1, 2, 3, 4]); lfsr
Out[2]: <Fibonacci LFSR: f(x) = 5x^4 + 3x^3 + x^2 + 1 over GF(7)>

In [3]: lfsr.state, lfsr.step()
Out[3]: (GF([1, 2, 3, 4], order=7), GF(4, order=7))

In [4]: lfsr.state, lfsr.step()
Out[4]: (GF([4, 1, 2, 3], order=7), GF(3, order=7))

In [5]: lfsr.state, lfsr.step()
Out[5]: (GF([6, 4, 1, 2], order=7), GF(2, order=7))

In [6]: lfsr.state, lfsr.step()
Out[6]: (GF([4, 6, 4, 1], order=7), GF(1, order=7))

In [7]: lfsr.state, lfsr.step()
Out[7]: (GF([5, 4, 6, 4], order=7), GF(4, order=7))

# Ending state
In [8]: lfsr.state
Out[8]: GF([0, 5, 4, 6], order=7)


Step the Fibonacci LFSR 5 steps in one call. This is more efficient than iterating one output at a time.

In [9]: c = galois.primitive_poly(7, 4)

In [10]: lfsr = galois.FLFSR(c.reverse(), state=[1, 2, 3, 4]); lfsr
Out[10]: <Fibonacci LFSR: f(x) = 5x^4 + 3x^3 + x^2 + 1 over GF(7)>

In [11]: lfsr.state
Out[11]: GF([1, 2, 3, 4], order=7)

In [12]: lfsr.step(5)
Out[12]: GF([4, 3, 2, 1, 4], order=7)

# Ending state
In [13]: lfsr.state
Out[13]: GF([0, 5, 4, 6], order=7)


Step the Fibonacci LFSR 5 steps backward. Notice the output sequence is the reverse of the original sequence. Also notice the ending state is the same as the initial state.

In [14]: lfsr.step(-5)
Out[14]: GF([4, 1, 2, 3, 4], order=7)

In [15]: lfsr.state
Out[15]: GF([1, 2, 3, 4], order=7)