Update the limb decomposition of the SIS #389
Merged
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.
Update the limb decomposition process in ring-SIS
This PR updates the way we decompose a list of field elements into limbs.
Prior state and motivation
The field elements were concatenated into bytes buffer in big-endian form and this bytes buffer was then split into limbs of short norm. The issue with this approach is that some limbs may contain bits from different field elements of the input slice.
These are blockers for the self-recursion. Indeed, for self-recursion we critically rely on the fact that we can recompute the original field element from its limbs as a polynomial evaluation.
Description of the new method
We split a slice of bytes representing an array of serialized field element in big-endian form into an array of limbs representing the same field elements in little-endian form. For instance, say our field is represented with 64 bits and we have the following field element
x = 0x0123456789abcdef
(0 being the most significant character and f being the least significant one) and our log norm bound is 16 (so 1 hex character = 1 limb). The function assigns the values of m to[f, e, d, c, b, a, ..., 3, 2, 1, 0]
. Additionally, we have the guarantee that 2 bits contributing to different field elements cannot be part of the same limb.Thanks to that, we have that
x = \sum_i limbs[i] * 16^i
Impacts on the code
All changes are concentrated in the package
ecc/bn254/fr/sis/
:cleanUp
to reinitialize the buffers of the ring-SIS instanceLimbDecomposeBytes
exposed to the user, which gives the same limb decomposition as the one that is used by theSum
functionlimbDecomposeBytes
that is used by bothSum
andLimbDecomposeBytes
Testing
Adds a test
TestLimbDecomposition
Performances impact
These changes add 1µs per field. This has little impact on the performances of "low-degree" instances, although their implementation is suboptimal from a performance perspective. However, the effect is significant on the "large-degree instances".
Benchmarks on an EC2-HPC6a