chiark / gitweb /
find-stretch.sage: Calculate stretch shifts for various block sizes.
This is an improved version which searches in the expected order.
For a block size w and shift c, define the domain length D(w, c) to be
the largest D such that
x, i |-> (x || x XOR (x << c))[i..i + w]
is strongly XOR-universal over {0, 1}^w, {0, 1, ... D - 1}.
The algorithm is to choose the shift c which maximizes
* maximizes floor(log_2(D(w, c))),
* minimizes c mod 8, and
* maximizes c
in that priority order.