Perf: Add-only emulated scalar multiplication #726
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.
I was trying to have a
ScalarMul()
circuit with only additions and no doublings. Ultimately, I could make the circuit work with less constraints than the previous right-to-left double-and-add circuit. So I looked in the literature to check if it was previously known and I found that Marc Joye of course did it in 2007 😅So this PR corresponds actually to Alg.2 of [CHES:Joye07] with some tweaks to make it work efficiently in-circuit:
triple()
method;R1
andR2
computations.Now when we use this new method in precompiles it saves:
ECRECOVER
:ECMUL
:P.S.: We can ditch the old
ScalarMul()
and replace it with the newScalarMulAddOnly()
once the PR is reviewed.