Skip to content

Commit 7b0dabc

Browse files
committed
hotfix: workaround gnark 0.10.0 unsoundness bug
A lot of time passed since gnark v0.10.0 unsoundness bug[0] was reported and fixed. We posponed the upgrade because the fixed release, v0.11.0, contains another vulnerability, an OOM[1], for which a fix has been in main since last November but no release appeared until now. Our options here are limited, and none quite happy: - We can `redirect` to a commit in `main`; - We can disable groth16 verifiers from the network, which we currently use; or - We can enforce that proofs have only one commitment, as the unsoundness can only be triggered with multiple commitments per proof. This implements the latter option, being the least invasive one. [0]: https://www.zellic.io/blog/gnark-bug-groth16-commitments [1]: GHSA-cph5-3pgr-c82g
1 parent eabda9c commit 7b0dabc

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

batcher/aligned-batcher/gnark/verifier.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020

2121
"github.com/consensys/gnark-crypto/ecc"
2222
"github.com/consensys/gnark/backend/groth16"
23+
bn254 "github.com/consensys/gnark/backend/groth16/bn254"
2324
"github.com/consensys/gnark/backend/plonk"
2425
"github.com/consensys/gnark/backend/witness"
2526
)
@@ -98,6 +99,18 @@ func verifyGroth16Proof(proofBytesRef C.ListRef, pubInputBytesRef C.ListRef, ver
9899
return false
99100
}
100101

102+
bn254Proof, ok := proof.(*bn254.Proof)
103+
if !ok {
104+
o.Logger.Warn("groth16 proof is not bn254")
105+
return false
106+
}
107+
numCommitments := len(bn254Proof.Commitments)
108+
if numCommitments > 1 {
109+
o.Logger.Warn("too many commitments for groth16 proof (unsound for v0.10.0)",
110+
"numCommitments", numCommitments)
111+
return false
112+
}
113+
101114
pubInputReader := bytes.NewReader(pubInputBytes)
102115
pubInput, err := witness.New(curve.ScalarField())
103116
if err != nil {

operator/pkg/operator.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
eigentypes "github.com/Layr-Labs/eigensdk-go/types"
3232
"github.com/consensys/gnark-crypto/ecc"
3333
"github.com/consensys/gnark/backend/groth16"
34+
bn254 "github.com/consensys/gnark/backend/groth16/bn254"
3435
"github.com/consensys/gnark/backend/plonk"
3536
"github.com/consensys/gnark/backend/witness"
3637
ethcommon "github.com/ethereum/go-ethereum/common"
@@ -598,6 +599,18 @@ func (o *Operator) verifyGroth16Proof(proofBytes []byte, pubInputBytes []byte, v
598599
return false
599600
}
600601

602+
bn254Proof, ok := proof.(*bn254.Proof)
603+
if !ok {
604+
o.Logger.Warn("groth16 proof is not bn254")
605+
return false
606+
}
607+
numCommitments := len(bn254Proof.Commitments)
608+
if numCommitments > 1 {
609+
o.Logger.Warn("too many commitments for groth16 proof (unsound for v0.10.0)",
610+
"numCommitments", numCommitments)
611+
return false
612+
}
613+
601614
pubInputReader := bytes.NewReader(pubInputBytes)
602615
pubInput, err := witness.New(curve.ScalarField())
603616
if err != nil {

0 commit comments

Comments
 (0)