Skip to content

Commit

Permalink
Merge pull request #374 from ConsenSys/fix/BatchVerifyMultiPoints-0
Browse files Browse the repository at this point in the history
fix(kzg): nb of digests in BatchVerifyMultiPoints should be nonzeo
  • Loading branch information
yelhousni authored Apr 11, 2023
2 parents a350a3a + 23812e3 commit ebbf692
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 1 deletion.
6 changes: 6 additions & 0 deletions ecc/bls12-377/fr/kzg/kzg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions ecc/bls12-378/fr/kzg/kzg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions ecc/bls12-381/fr/kzg/kzg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions ecc/bls24-315/fr/kzg/kzg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions ecc/bls24-317/fr/kzg/kzg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions ecc/bn254/fr/kzg/kzg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions ecc/bw6-633/fr/kzg/kzg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions ecc/bw6-756/fr/kzg/kzg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions ecc/bw6-761/fr/kzg/kzg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion internal/generator/kzg/template/kzg.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

var (
ErrInvalidNbDigests = errors.New("number of digests is not the same as the number of polynomials")
ErrZeroNbDigests = errors.New("number of digests is zero")
ErrInvalidPolynomialSize = errors.New("invalid polynomial size (larger than SRS or == 0)")
ErrVerifyOpeningProof = errors.New("can't verify opening proof")
ErrVerifyBatchOpeningSinglePoint = errors.New("can't verify batch opening proof at single point")
Expand Down Expand Up @@ -265,7 +266,7 @@ func BatchOpenSinglePoint(polynomials [][]fr.Element, digests []Digest, point fr
for i := 1 ; i < len(polynomials); i++ {
gammas[i].Mul(&gammas[i-1], &gamma)
}

for i := 1; i < len(polynomials); i++ {
i := i
parallel.Execute(len(polynomials[i]), func(start, end int) {
Expand Down Expand Up @@ -366,6 +367,11 @@ func BatchVerifyMultiPoints(digests []Digest, proofs []OpeningProof, points []fr
return ErrInvalidNbDigests
}

// len(digests) should be nonzero because of randomNumbers
if len(digests) == 0 {
return ErrZeroNbDigests
}

// if only one digest, call Verify
if len(digests) == 1 {
return Verify(&digests[0], &proofs[0], points[0], srs)
Expand Down

0 comments on commit ebbf692

Please # to comment.