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

refactor: plonk.Setup takes kzg srs in canonical and lagrange form #953

Merged
merged 6 commits into from Dec 11, 2023

Conversation

gbotrel
Copy link
Collaborator

@gbotrel gbotrel commented Dec 6, 2023

This PR changes the signature of plonk.Setup(...) and adds an additional parameter; the kzg.SRS in Lagrange form.

In production, this can be computed using gnark-crypto ToLagrangeG1 helper from a canonical SRS.

For test purposes when we know the tau used for generating the canonical srs, we can take a quicker path (see test/unsafekzg package which offers a convenient api to generate and cache in memory / on disk srs for test purposes).

@ThomasPiellard
Copy link
Collaborator

ThomasPiellard commented Dec 11, 2023

Couldn't we use an option to pass the kzg SRS in Lagrange form to the Setup ? When using unsafekzg.NewSRS it's ok since the Lagrange srs is generated quickly anyway, but if one uses a production ready srs (in canonical) for testing purpose one might not want to generate the corresponding lagrange srs each time the size of the circuit changes. Just a suggestion

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 good. A few comments though but they are not blocking.

test/unsafekzg/kzgsrs.go Outdated Show resolved Hide resolved
test/unsafekzg/kzgsrs.go Outdated Show resolved Hide resolved
@ivokub
Copy link
Collaborator

ivokub commented Dec 11, 2023

Imo on thing we could consider in the future is to have a lazy SRS. We can store it on disk and only when we actually we read it to memory (using mmap). Or more better, because the key is very structured we can have method a la Get(index int) and then we read exactly from the location we need by computing the exact byte location on disk.

@gbotrel
Copy link
Collaborator Author

gbotrel commented Dec 11, 2023

Couldn't we use an option to pass the kzg SRS in Lagrange form to the Setup ? When using unsafekzg.NewSRS it's ok since the Lagrange srs is generated quickly anyway, but if one uses a production ready srs (in canonical) for testing purpose one might not want to generate the corresponding lagrange srs each time the size of the circuit changes. Just a suggestion

@ThomasPiellard yes good idea but it changes the PlonK prover code too a bit so will do it in another PR

@gbotrel gbotrel merged commit 056a6bc into master Dec 11, 2023
7 checks passed
@gbotrel gbotrel deleted the refactor/kzgsetup branch December 11, 2023 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants