refactor: generic KZG and Groth16 verifier#840
Conversation
49824ef to
3474c12
Compare
|
@yelhousni - the PR is not fully done yet, but I think its kind of ready for review (to validate the design). There are still some todos:
Particularly, have a look at the generic interfaces |
Summary✅ Passed: 5737 🚧 Skipped
|
This looks clean, nice work! I think the design and interfaces make sense so we can ditch the old implementations and make the new wrapped one default. Once we have that, I would like to add BLS24 (2-chain) and BW6 (emulated) to familiarize myself with the code. |
In two-chains we use frontend.Variable for scalars, but this prevents type switching (we have frontend.Variable scalars for both BLS12-377 and BLS24-315). By adding one more type parameter we do not have the ambiguity.
d149112 to
26d7e28
Compare
These tasks done. I think from my side the PR is ready. Additionally, I rebased on top of master to take use of the refactoring in the gnark-crypto and updated dependencies. I'll leave cleaning up the native EC gadgets as a separate PR. I think we can have other discussions there i.e. we can try to implement Jacobian operations such that it also implements |
|
And requesting re-review. Nothing much has changed (except adding documentation, examples more compatibility etc.), and I'm confident it didn't break anything after the last review. But just in case if you want to. Otherwise will merge as-is. |
Description
This PR introduces a generic KZG and Groth16 verifier gadget in gnark. Currently we had typed gadgets for every 2-chain but with future introduction of PLONK verifier it would be good to have a single implementation for KZG, Groth16 and PLONK. This change still requires some setting up per curve (instantiating the new Curve and Pairing generic interfaces), but otherwise KZG/Groth16 are completely curve-agnostic.
In order to achieve it, I also changed the curve operations API for the 2-chain curves to match non-native implementations.
This is a breaking change as existing typed implementations are removed.
Type of change
How has this been tested?
How has this been benchmarked?
Checklist:
golangci-lintdoes not output errors locallycc @yelhousni