Skip to content

Conversation

@Tabaie
Copy link
Contributor

@Tabaie Tabaie commented Mar 17, 2023

Introducing BSB22-based api.Commit for Plonk. The commitment is KZG, using the same SRS as Plonk. Like in the Groth16 version, it is hashed onto the fr field using Sha256 and then usable in Fiat-Shamir challenges.

Consistency with the Plonk witness is enforced by replacing the constraint equation $q_L.f_L+q_R.f_R+q_O.f_O+q_M.f_L.f_R+(q_C+PI)=0$ with $q_L.f_L+q_R.f_R+q_O.f_O+q_M.f_L.f_R+(q_C+PI_1+q'_C.PI_2)=0$ as if this feature is a custom gate. $PI_2$ is the commitment shipped to the verifier and $q'_C$ is a sparse preprocessed binary polynomial (i.e. with values $0,1$ on the subgroup.)
For any committed value, say $w_m$ or the $m$'th value in the witness vector $w$, we add a constraint of the form $q_L(j)=-1, f_L(j)=w_m, PI_2(j)=w_m$ thus binding the value in the commitment to the one used in normal constraints.
The hashed-to-field commitment $C$ is injected into the circuit as if it were a public value. That is, for some $j$ we have a constraint where $q_L(j)=-1$ and other selectors are $0$. When computing $PI(\zeta)$, the verifier simply adds $C.L_j(\zeta)$ to the sum.

gbotrel and others added 30 commits February 28, 2023 13:25
The example in `README.md` (still) does not compile. `BN254` has a `ScalarField()` method now, and should not be passed directly.
committed := make([]int, len(v))

for i, vI := range v { // TODO @Tabaie Perf; If public, just hash it
vINeg := builder.Neg(vI).(expr.Term)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should handle the error here if the variable is constant (or anything else than a Term) ? Otherwise we get a message like this: parse circuit: interface conversion: frontend.Variable is *big.Int, not expr.Term, not sure if it's very explicit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in new commit 👍

@gbotrel gbotrel mentioned this pull request Mar 21, 2023
@ThomasPiellard
Copy link
Collaborator

LGTM, perhaps for a later PR we should definitely remove the constraints linked to the commitments of public inputs, as these constraints are duplicated at the beginning of the circuit when it is compiled, could blow up the number of constraints if there are a lot of public inputs...

@ThomasPiellard ThomasPiellard self-requested a review March 22, 2023 18:47
@Tabaie
Copy link
Contributor Author

Tabaie commented Mar 24, 2023

LGTM, perhaps for a later PR we should definitely remove the constraints linked to the commitments of public inputs, as these constraints are duplicated at the beginning of the circuit when it is compiled, could blow up the number of constraints if there are a lot of public inputs...

My original plan was to let both prover and verifier conventionally hash the public committed values, but after today's standup discussion seems like that's off the table and we'll have to stick to this method to make the verifier's life easier.

}
commitmentVar := builder.Neg(outs[0]).(expr.Term)
commitmentConstraintIndex := builder.cs.GetNbConstraints()
builder.addPlonkConstraint(sparseR1C{xa: commitmentVar.VID, qL: commitmentVar.Coeff, commitment: constraint.COMMITMENT}) // value will be injected later
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this constraint exactly?
-xa + __ == 0

?

@Tabaie Tabaie merged commit c76ba9d into develop Mar 29, 2023
@Tabaie Tabaie deleted the 406-bsb22-commitments-plonk branch March 29, 2023 00:13
@Tabaie Tabaie mentioned this pull request Apr 30, 2023
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.

5 participants