Skip to content
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: special squaring for sparse elements in the pairing algorithm #772

Merged
merged 7 commits into from Jul 17, 2023

Conversation

yelhousni
Copy link
Contributor

PR #763 triggered some unnecessary additions by 0 in pairing circuits (for 2-chains). It also happens for emulated pairings but it's hidden by how field emulation works. @ivokub tracked these occurrences and suggested to handle them in the pairing algorithm. These happen at the second iteration of the Miller loop. In fact, at this point, for a single pairing, the accumulator is a sparse element in Fpk (it's actually just the assigned line). So in this PR instead of calling the plain Square function we implement a special Square034 that takes into account this sparsity. The benefit is not huge but still, e.g.:

PLONK bench of emulated BN254 pairing in a BN254 circuit:

old: 8075956 scs
new: 8066505 scs
diff: 9451 scs

@yelhousni yelhousni added this to the v0.9.0 milestone Jul 12, 2023
@yelhousni yelhousni requested a review from ivokub July 12, 2023 12:44
@yelhousni yelhousni changed the title Perf/pairing add0 Perf: special squaring for sparse elements in the pairing algorithm Jul 12, 2023
@yelhousni yelhousni merged commit 6c150c9 into develop Jul 17, 2023
5 checks passed
@yelhousni yelhousni deleted the perf/pairing-add0 branch July 17, 2023 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants