-
Notifications
You must be signed in to change notification settings - Fork 198
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
Feat/plookup #102
Merged
Merged
Feat/plookup #102
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR integrates plookup, the vector version and table version, and a protocol to prove that 2 commitments are permuted versions of one another.
Description
The protocol relies on the KZG commitment scheme but it can be used with any polynomial commitment scheme.
Table
A
Table
is a slice of fr.Element, on which the Sort method can be called. The API takesTable
as parameters.Lookup vector
func ProveLookupVector(srs *kzg.SRS, f, t Table) (ProofLookupVector, error)
where thesrs
is the public srs used for KZG. It generates a proof that f contains only elements that are int
.f
andt
need not be of the same size.The verification function is
ProveLookupVector(srs *kzg.SRS, f, t Table) (ProofLookupVector, error)
.Lookup table
func ProveLookupTables(srs *kzg.SRS, f, t []Table) (ProofLookupTables, error)
generates a proof that of the columns off
(represented by a list of Table) are all int
. The rows off
andt
need this time to be of the same size.The verification function is
VerifyLookupTables(srs *kzg.SRS, proof ProofLookupTables) error
`Permutation
func Prove(srs *kzg.SRS, t1, t2 []fr.Element) (Proof, error)
, generates a proof thet1
andt2
are permuted versions of one another.The verification function is
Verify(srs *kzg.SRS, proof Proof) error
Example
Here is a full example for generating a lookup vector proof.
First, one needs to generate the public lookup vector:
The public lookup vector needs to be committed somewhere. We commit it, but before we sort it. The reason is that in the proof, there is a commitment to the sorted version of the lookup vector.
Now we generate a vector whose entries are in the lookup vector.
We build the proof:
proof, _ := ProveLookupVector(srs, fvector, lookupVector)
Now to verify the proof, we check that the
t
field in the proof corresponds to the commitment of the lookup vector. It will because the lookup vector has been committed sorted. Were that not the case, the prover should have had published a permutation proof the thet
field of the proof is a commitment of a permuted version of the lookup vector.The reason why the
lookupVectorCommitment
is done as a side step and is not in the the signature. ofVerifyLookupVector
is that the proof is a standalone object, and I can imagine that in certain situations one would only want to check consistency of a proof alone.Internal
The implementation follows the ideas of the paper with some adaptations. The permutation proof is used for a technical reason but can be useful in itself for various protocols. The technical reason is the following. In the LookupTable version, the rows of t are folded using a random challenge, and then the LookupVector is called on the result, but the LookupVector prover needs to sort the table t beforehand. The LookupVector proof contains a commitment to the sorted version of t. In the vector case it's not a problem because t can be committed sorted. In the Table case, it becomes a problem because the challenge changes each time, so the order cannot be known in advance. The solution that I came up with is to generate a permutation proof that the folded commitment of t is in fact a permutation of the folded commitment of the public t.
Note: at some point in the plookup protocol, 2 vectors f and t need to be concatenated, and sorted so the values of f appear in the same order as in t. I didn't find an efficient algo to do it, so I just concatenated the 2 vectors and sorted the result. If an efficient algo to do so can be found then the permutation proof can be avoided.
Status
The tests are passing.
The algos do not use channel or anything and the efficiency can be improved.