-
Notifications
You must be signed in to change notification settings - Fork 504
Groth16 Multicommits #702
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
Groth16 Multicommits #702
Conversation
constraint/commitment.go
Outdated
| res := make([]uint64, len(commitments)) | ||
| for i := range res { | ||
| res[i] = uint64(commitments[i].CommitmentIndex) | ||
| func (c Commitments) CommitmentWireIndexes() []int { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe evaluate if instead of computing all the index (wires, commited etc) during proving time, it would not be worth it to store these slices in the CommitmentInfo data struct? Particularly to avoid allocations in the prover.
|
|
||
| if vk.HasCommitment { | ||
| kSum.AddMixed(&proof.Commitment) | ||
| for i := range proof.Commitments { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same, my understanding is we probably won't go over comuple of commitments, but if we do, this place might be a good candidate for a batchAddition
backend/groth16/internal/utils.go
Outdated
| import "math/big" | ||
|
|
||
| // DivideByThresholdOrList divides x into two sub-lists. list must be sorted, non-repeating and contain no value less than indexThreshold | ||
| func DivideByThresholdOrList(indexThreshold int, list []int, x []*big.Int) (ltOrInList, gtAndNotInList []*big.Int) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do that in place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced, but it still allocates a slice of size len(list), which in this application is small.
frontend/cs/r1cs/api.go
Outdated
| if t.VID < builder.cs.GetNbPublicVariables() { | ||
| nbPublicCommitted++ | ||
| } else { | ||
| // Cannot commit to a secret variable that has already been committed to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out of curiosity; why can't we just continue here and ignore that? Will comitting to a commitment help in anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of how the result of an api.Commit must be usable as a fiat-shamir challenge, it must have a "one-way" dependence on every variable input to this function. However, the way the commitment scheme is verified is Groth16 necessitates that every private variable can be used in one commitment at most. So if it were needed in multiple commitments, the next best thing is to commit to its commitment (commitments to commitments are easy, they're just conventional hashes.)
internal/utils/search.go
Outdated
| @@ -0,0 +1,18 @@ | |||
| package utils | |||
|
|
|||
| // BinarySearch attempts to find the target in x. If not found, returns false and the index where the target would be inserted. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use go standard std Find method?
| }) | ||
| } | ||
|
|
||
| func hollow(c frontend.Circuit) frontend.Circuit { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you document a bit more this file / the functions?
backend/groth16/bls12-377/setup.go
Outdated
| commitmentWires := commitmentInfo.CommitmentIndexes() | ||
| privateCommitted := commitmentInfo.GetPrivateCommitted() | ||
| nbPrivateCommittedWires := internal.NbElements(privateCommitted) | ||
| //nbPrivateCommittedWires, privateCommitted, publicAndCommitmentCommitted := |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deadcode
Equivalent of #668 for Groth16.