fix: use emulated arithmetic for GLV decomp #1167
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.
Description
We use GLV for scalar multiplication in 2-chains (BLS12-377 and BLS24-315). For the decomposition of scalar to be valid we have to check that
s1 + λ s2 = swheresis the initial scalar ands1,s2are the decomposed values (width length 127 bits).For BLS12-377 we can perform this check using native arithmetic as we constrain s1, s2, λ to all be 127 bits and we never overflow the outer curve scalar field (width 377 bits).
However, for BLS24-315 we have
λwith256bits and in this case the checks1 + λ s2 = smay overflow the native field. We compensate for it by giving additional output from the hint which cancels out the overflowed value, but this gives the malicious prover some advantage for finding invalid inputs.Safer approach would be to perform the arithmetic using non-native arithmetic, which this PR introduces.
Type of change
How has this been tested?
Existing tests work.
How has this been benchmarked?
No impact on pairing/ML/FE.
Checklist:
golangci-lintdoes not output errors locally