Canonically encode powers of primitive element e #64
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is no behaviour change in this PR.
Currently, the primitive element
egenerating the multiplicative group of GF(1024) is encoded as an integer inGF1024_EXP[]as({9}, {15}), or303. Because of this choice, the table is generated in the following way:For an element
(v1, v0), we computee*(v1, v0) = (v1', v0')as:(from https://github.com/sipa/ezbase32/blob/master/bech32.cpp#L90-L122)
After asking sipa about this choice of encoding, he couldn't recall why the
({9},{15})was chosen. It has no effect on the checksum, as we are not modifying the choice of primitive element itself, only the encoding of it in theGF1024_EXP[]table. For clarity, this PR instead uses the clearer choice of({1},{0})to encodee. This encoding is simpler because elementsa*e + bin GF(1024) are then directly encoded as(a, b). The multiplication byethen becomes:Where the
{9}and{23}come directly from the choice of modulus for the extension fieldx^2 + 9*x + 23.We then update the syndrome computation values accordingly, which just encode powers of two * powers of
e.