-
Notifications
You must be signed in to change notification settings - Fork 366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Perf: save some negations in emulated pairings #816
Conversation
Yes, I would assume this is due to how field emulation works. When we negate then we increase the overflow of the limbs (because we have to add the subtraction padding to avoid underflowing individual limbs). When the overflow is larger, then we may hit the amortized reduction (for additions) sooner and we have to carry bigger partitions in the equality check. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a duplicate line in bn254 precomputation. Otherwise looks good.
PS, if you removed the benchmark from bls12377, then maybe also remove it from bls24315? It is not a proper benchmark anyway (doesn't depend on the number of loops).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
@feltroidprime pointed out this morning that pre-computing
-x/y
in emulated pairings would save lines negations at each double/add step in the Miller loop. While it shouldn't in native fields, the idea is interesting for emulated fields. I tried this for 2-chains and emulated BN254 and BLS12-381:However this PR is worth it for Plonk because the addition gates are not free. We save 5960 constraints for BLS12-381 and 2896 for BN254. I applied the changes to 2-chains as well, to homogenise the implementations in native and emulated packages.
Type of change
Please delete options that are not relevant.
How has this been tested?
Please describe the tests that you ran or implemented to verify your changes. Provide instructions so we can reproduce.
How has this been benchmarked?
Benchmarks on fixed and variable input pairings of different sizes (1 to 10).
Checklist:
golangci-lint
does not output errors locally