Skip to content

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 type: perf dep: linea Issues affecting Linea downstream labels Jul 12, 2023
@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
@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

Labels

dep: linea Issues affecting Linea downstream type: perf

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants