Skip to content

Commit bcfe760

Browse files
committed
fix(galoisd): include public commitment when creating fixed vk
Signed-off-by: aeryz <[email protected]>
1 parent 4c45566 commit bcfe760

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

galoisd/grpc/bls12381_server.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
"github.com/consensys/gnark/frontend"
3333
// "github.com/consensys/gnark/frontend/cs/r1cs"
3434
gadget "github.com/consensys/gnark/std/algebra/emulated/sw_bn254"
35-
"github.com/consensys/gnark/std/math/emulated"
35+
// "github.com/consensys/gnark/std/math/emulated"
3636
"github.com/consensys/gnark/std/recursion/groth16"
3737
"github.com/holiman/uint256"
3838
"github.com/rs/zerolog/log"
@@ -142,7 +142,6 @@ func (p *proverServerBls12381) Poll(ctx context.Context, pollReq *grpc.PollReque
142142
commitmentHash := cometbn254.HashToField(innerProof.ProofCommitment.Marshal())
143143
bls12381Witness := &bls12381gadget.Circuit{
144144
// verifying key is baked in, so we don't set here since it has no effect on the witness generation
145-
// VerifyingKey: circuitVk,
146145
InnerWitness: circuitWitness,
147146
Proof: circuitProof,
148147
CommitmentHash: commitmentHash.BigInt(new(big.Int)),
@@ -377,6 +376,7 @@ func loadOrCreateBls12381(r1csPath, pkPath, vkPath, innerR1csPath, innerPkPath,
377376
}
378377

379378
verifyingKey, err := groth16.ValueOfVerifyingKeyFixed[gadget.G1Affine, gadget.G2Affine, gadget.GTEl](&vkInner)
379+
verifyingKey.PublicAndCommitmentCommitted = vkInner.PublicAndCommitmentCommitted
380380

381381
if err != nil {
382382
return cs, pk, vk, csInner, pkInner, vkInner, err
@@ -385,13 +385,10 @@ func loadOrCreateBls12381(r1csPath, pkPath, vkPath, innerR1csPath, innerPkPath,
385385
log.Info().Msg("Compiling circuit...")
386386
r1csInstance, err := bls12381gadget.Compile(
387387
groth16.PlaceholderProof[gadget.G1Affine, gadget.G2Affine](&csInner),
388-
groth16.Witness[gadget.ScalarField]{
389-
Public: make([]emulated.Element[gadget.ScalarField], csInner.GetNbPublicVariables()),
390-
},
388+
groth16.PlaceholderWitness[gadget.ScalarField](&csInner),
391389
verifyingKey,
392390
)
393391

394-
// r1csInstance, err := frontend.Compile(ecc.BLS12_381.ScalarField(), r1cs.NewBuilder, circuit, frontend.WithCompressThreshold(300))
395392
if err != nil {
396393
return cs, pk, vk, csInner, pkInner, vkInner, err
397394
}

galoisd/pkg/lightclient/bls12381/circuit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717

1818
type Circuit struct {
1919
Proof groth16.Proof[sw_bn254.G1Affine, sw_bn254.G2Affine]
20-
InnerWitness groth16.Witness[sw_bn254.ScalarField]
20+
InnerWitness groth16.Witness[sw_bn254.ScalarField] `gnark:",public"`
2121
// we are using an embedded constant verifying key since it's easier and doesn't require a vkhash
2222
verifyingKey groth16.VerifyingKey[sw_bn254.G1Affine, sw_bn254.G2Affine, sw_bn254.GTEl] `gnark:"-"`
2323
CommitmentHash frontend.Variable `gnark:",public"`

0 commit comments

Comments
 (0)