Skip to content

perf: optimize class equivalence check for BLS12 final exp #1207

Merged
yelhousni merged 15 commits intomasterfrom
perf/eliminate-finalExp-bls
Jul 29, 2024
Merged

perf: optimize class equivalence check for BLS12 final exp #1207
yelhousni merged 15 commits intomasterfrom
perf/eliminate-finalExp-bls

Conversation

@yelhousni
Copy link
Copy Markdown
Contributor

@yelhousni yelhousni commented Jul 17, 2024

Description

Instead of applying Th.1 of https://eprint.iacr.org/2024/640.pdf naively as in #1173 ans #1202 we can scale the miller loop result by some factors:

  • for BLS12-381 by 27th root and p-th root where p=(1-u)/3
  • for BLS12-377 by p'-th root where p'=12(u-1)

and use the optimal exponent q-u instead of r. This is based on a personal communication (and a lot of help) from Andrija Novakovic @akinovak: https://gist.github.com/akinovak/0db531d350b95ccec682666b2257db77

Type of change

  • New feature (non-breaking change which adds functionality)

How has this been tested?

pairing tests pass.

How has this been benchmarked?

  • BLS12-381:
    This PR saves 3,369,246 scs for a PairingCheck.
  • BLS12-377:
    This PR saves 21,989 scs in the PairingCheck and in the PLONK native aggregation circuit.

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I did not modify files generated from templates
  • golangci-lint does not output errors locally
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@yelhousni yelhousni marked this pull request as draft July 17, 2024 15:02
@yelhousni yelhousni changed the title Perf/eliminate final exp bls perf: optimize class equivalence check for BLS12-381 final exp Jul 17, 2024
@yelhousni yelhousni changed the title perf: optimize class equivalence check for BLS12-381 final exp perf: optimize class equivalence check for BLS12 final exp Jul 18, 2024
@yelhousni yelhousni self-assigned this Jul 18, 2024
@yelhousni yelhousni added this to the v0.9.0 milestone Jul 18, 2024
@yelhousni yelhousni marked this pull request as ready for review July 18, 2024 16:33
@yelhousni yelhousni requested a review from ivokub July 23, 2024 16:28
@yelhousni yelhousni added the dep: linea Issues affecting Linea downstream label Jul 23, 2024
Copy link
Copy Markdown
Collaborator

@ivokub ivokub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yelhousni yelhousni requested a review from ivokub July 25, 2024 13:14
Copy link
Copy Markdown
Collaborator

@ivokub ivokub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes good. I only now noticed that in FinalExpCheck we have indicated that we return *E12, but always return nil. I think we can change the the function signature to indicate that.

And, now after #1209 is merged, maybe it would make sense to also have methods for other curves for returning the FinalExpCheck result? Long-term this allows us to amend the std/algebra/Pairing interface so that we can also prove that final exponentiation doesn't hold.

Comment thread std/algebra/emulated/fields_bls12381/e12_pairing.go Outdated
Comment thread std/algebra/native/fields_bls12377/e12_pairing.go Outdated
Copy link
Copy Markdown
Collaborator

@ivokub ivokub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@yelhousni yelhousni merged commit aa6efa4 into master Jul 29, 2024
@yelhousni yelhousni deleted the perf/eliminate-finalExp-bls branch July 29, 2024 14:45
This was referenced Aug 4, 2024
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.

2 participants