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: emulated BN254 pairing #566

Merged
merged 59 commits into from
Mar 17, 2023
Merged

Perf: emulated BN254 pairing #566

merged 59 commits into from
Mar 17, 2023

Conversation

yelhousni
Copy link
Contributor

Taking into account the new range check gadget, this PR removes almost 1M R1CS constraints from the emulated BN254 pairing (verified in a BN254 SNARK). It mostly follows "Pairings in R1CS" paper.

ivokub and others added 30 commits February 21, 2023 12:38
Backend options were split into prover and solver options. Usually when running
the prover we set the solver options using backend.WithSolverOptions. But in
tests makes sense that if we set `test.WithSolverOptions` then these options
are also applied to the solver when run by the prover.
There are a lot of hints in the package. The preferred way of accessing all the
hints is using GetHints()
Copy link
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.

Looks perfect! I only made some modifications to keep the interfaces similar, and didn't change anything in the computation itself.

Before merging I would just rebase on top of develop just in case to see we're not reintroducing regressions. There have been several updates to field emulation. If you are OK with it then I can do it myself and force push.

However, when I run TestPairTestSolve locally in test engine then 10% cases fail. I'll have a look to understand if it is due to field emulation. I would postpone merging until then.

@yelhousni
Copy link
Contributor Author

@ivokub rebased on develop which includes now your #579 subtraction bug fix, so PR is ready!

Copy link
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.

Very good! I only removed the test which runs the profiler.

@yelhousni
Copy link
Contributor Author

yelhousni commented Mar 17, 2023

Some R1CS stats:
1 pairing: 2029932 = ~2M
2 pairings: 2614251 = ~2.6M
3 pairings: 3209766 = ~3.2M

@yelhousni yelhousni merged commit a4d7b88 into develop Mar 17, 2023
@yelhousni yelhousni deleted the perf/bn254-pairing branch March 17, 2023 17:20
This was referenced Mar 20, 2023
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.

2 participants