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

fix: allow unreplaced BSB22 commitment hint in solver #507

Merged
merged 1 commit into from
Mar 8, 2023

Conversation

ivokub
Copy link
Collaborator

@ivokub ivokub commented Mar 1, 2023

Related #504.

In order to enable running full test suite where we use commitments we need to have the commitment available for the solver. I don't know what is a good way to do this, but this patch allows to continue with #472.

First, I register the hint in frontend/r1cs init. This gives solver access to the hint when run in the same process as the compiler. The hint is private so it isn't possible to provide it manually.

We also check if either debug tag is set or we run as a Go test (i.e. the executable name ends in .test). Only so we have a dummy commitment (zero).

Otherwise, we return an error, as before.

@ivokub ivokub requested review from gbotrel and Tabaie March 1, 2023 14:09
@ivokub ivokub self-assigned this Mar 1, 2023
@ivokub ivokub added the bug Something isn't working label Mar 1, 2023
@ivokub ivokub added this to the v0.9.0 milestone Mar 1, 2023
@ivokub ivokub force-pushed the fix/commitment-hint-in-solver branch from 9116e40 to aee4308 Compare March 6, 2023 11:05
@ivokub ivokub mentioned this pull request Mar 6, 2023
3 tasks
@gbotrel
Copy link
Collaborator

gbotrel commented Mar 6, 2023

so, right now we have a "CommitInfo" bits in the ... constraint/System --> so we know:

HintID                 solver.HintID

at solve time, in all constraint system.

Shouldn't the R1CS.Solve() and SparseR1CS.Solve() methods check

if (commitment) and !alreadyReplaced(commitment.HintID) {
replace with something
}

? (commitmnet could already be repalced by the groth16 / plonk prover). Or did that change it latest design cc @Tabaie ?

@Tabaie
Copy link
Contributor

Tabaie commented Mar 7, 2023

so, right now we have a "CommitInfo" bits in the ... constraint/System --> so we know:

HintID                 solver.HintID

at solve time, in all constraint system.

Shouldn't the R1CS.Solve() and SparseR1CS.Solve() methods check

if (commitment) and !alreadyReplaced(commitment.HintID) {
replace with something
}

? (commitmnet could already be repalced by the groth16 / plonk prover). Or did that change it latest design cc @Tabaie ?

Yes I think that makes sense. Ideally the prover replaces the hint using proving key, but if that hasn't happened the solver would put a fake hint there. That at least is my understanding of what this PR does.
One other thing we could do is to actually use the latter version of the hint in the api.Commit function and register that hint by default so that we get the fallback case for free.

@ivokub
Copy link
Collaborator Author

ivokub commented Mar 7, 2023

so, right now we have a "CommitInfo" bits in the ... constraint/System --> so we know:

HintID                 solver.HintID

at solve time, in all constraint system.
Shouldn't the R1CS.Solve() and SparseR1CS.Solve() methods check

if (commitment) and !alreadyReplaced(commitment.HintID) {
replace with something
}

? (commitmnet could already be repalced by the groth16 / plonk prover). Or did that change it latest design cc @Tabaie ?

Yes I think that makes sense. Ideally the prover replaces the hint using proving key, but if that hasn't happened the solver would put a fake hint there. That at least is my understanding of what this PR does. One other thing we could do is to actually use the latter version of the hint in the api.Commit function and register that hint by default so that we get the fallback case for free.

Actually this is exactly what this PR is doing. frontend package registers the hint, but we do not register it in the constraint.RegisterHints (so the hint is only available if the frontend package is imported).

@gbotrel gbotrel merged commit c439508 into develop Mar 8, 2023
@gbotrel gbotrel deleted the fix/commitment-hint-in-solver branch March 8, 2023 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants