From b45c6206ab7550991e5657d6354ba8fa5275beae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 Nov 2023 18:47:22 +0000 Subject: [PATCH] Bump github.com/consensys/gnark-crypto from 0.12.0 to 0.12.1 Bumps [github.com/consensys/gnark-crypto](https://github.com/consensys/gnark-crypto) from 0.12.0 to 0.12.1. - [Release notes](https://github.com/consensys/gnark-crypto/releases) - [Changelog](https://github.com/Consensys/gnark-crypto/blob/master/CHANGELOG.md) - [Commits](https://github.com/consensys/gnark-crypto/compare/v0.12.0...v0.12.1) --- updated-dependencies: - dependency-name: github.com/consensys/gnark-crypto dependency-type: indirect ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +-- .../gnark-crypto/ecc/bls12-377/g1.go | 34 ++++++++++++++----- .../gnark-crypto/ecc/bls12-377/g2.go | 34 ++++++++++++++----- .../ecc/bls12-377/internal/fptower/e12.go | 8 ++++- .../gnark-crypto/ecc/bls12-381/g1.go | 34 ++++++++++++++----- .../gnark-crypto/ecc/bls12-381/g2.go | 34 ++++++++++++++----- .../ecc/bls12-381/internal/fptower/e12.go | 8 ++++- .../consensys/gnark-crypto/ecc/bn254/g1.go | 34 ++++++++++++++----- .../consensys/gnark-crypto/ecc/bn254/g2.go | 34 ++++++++++++++----- .../ecc/bn254/internal/fptower/e12.go | 8 ++++- vendor/modules.txt | 2 +- 12 files changed, 175 insertions(+), 61 deletions(-) diff --git a/go.mod b/go.mod index 5515a5f07..635aa8790 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,7 @@ require ( github.com/bits-and-blooms/bitset v1.7.0 // indirect github.com/cespare/xxhash/v2 v2.1.1 // indirect github.com/consensys/bavard v0.1.13 // indirect - github.com/consensys/gnark-crypto v0.12.0 // indirect + github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/go-logfmt/logfmt v0.5.0 // indirect diff --git a/go.sum b/go.sum index aa6a9e851..c0f150268 100644 --- a/go.sum +++ b/go.sum @@ -39,8 +39,8 @@ github.com/cloudflare/redoctober v0.0.0-20171127175943-746a508df14c/go.mod h1:6S github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= -github.com/consensys/gnark-crypto v0.12.0 h1:1OnSpOykNkUIBIBJKdhwy2p0JlW5o+Az02ICzZmvvdg= -github.com/consensys/gnark-crypto v0.12.0/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= +github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= +github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bls12-377/g1.go b/vendor/github.com/consensys/gnark-crypto/ecc/bls12-377/g1.go index 17ea4160f..e1bc1809f 100644 --- a/vendor/github.com/consensys/gnark-crypto/ecc/bls12-377/g1.go +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bls12-377/g1.go @@ -184,17 +184,30 @@ func (p *G1Jac) Set(a *G1Jac) *G1Jac { // Equal tests if two points (in Jacobian coordinates) are equal func (p *G1Jac) Equal(a *G1Jac) bool { - - if p.Z.IsZero() && a.Z.IsZero() { - return true + // If one point is infinity, the other must also be infinity. + if p.Z.IsZero() { + return a.Z.IsZero() + } + // If the other point is infinity, return false since we can't + // the following checks would be incorrect. + if a.Z.IsZero() { + return false } - _p := G1Affine{} - _p.FromJacobian(p) - _a := G1Affine{} - _a.FromJacobian(a) + var pZSquare, aZSquare fp.Element + pZSquare.Square(&p.Z) + aZSquare.Square(&a.Z) - return _p.X.Equal(&_a.X) && _p.Y.Equal(&_a.Y) + var lhs, rhs fp.Element + lhs.Mul(&p.X, &aZSquare) + rhs.Mul(&a.X, &pZSquare) + if !lhs.Equal(&rhs) { + return false + } + lhs.Mul(&p.Y, &aZSquare).Mul(&lhs, &a.Z) + rhs.Mul(&a.Y, &pZSquare).Mul(&rhs, &p.Z) + + return lhs.Equal(&rhs) } // Neg computes -G @@ -421,8 +434,11 @@ func (p *G1Jac) mulWindowed(a *G1Jac, s *big.Int) *G1Jac { var res G1Jac var ops [3]G1Jac - res.Set(&g1Infinity) ops[0].Set(a) + if s.Sign() == -1 { + ops[0].Neg(&ops[0]) + } + res.Set(&g1Infinity) ops[1].Double(&ops[0]) ops[2].Set(&ops[0]).AddAssign(&ops[1]) diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bls12-377/g2.go b/vendor/github.com/consensys/gnark-crypto/ecc/bls12-377/g2.go index 0f06e46fa..c256d8210 100644 --- a/vendor/github.com/consensys/gnark-crypto/ecc/bls12-377/g2.go +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bls12-377/g2.go @@ -173,17 +173,30 @@ func (p *G2Jac) Set(a *G2Jac) *G2Jac { // Equal tests if two points (in Jacobian coordinates) are equal func (p *G2Jac) Equal(a *G2Jac) bool { - - if p.Z.IsZero() && a.Z.IsZero() { - return true + // If one point is infinity, the other must also be infinity. + if p.Z.IsZero() { + return a.Z.IsZero() + } + // If the other point is infinity, return false since we can't + // the following checks would be incorrect. + if a.Z.IsZero() { + return false } - _p := G2Affine{} - _p.FromJacobian(p) - _a := G2Affine{} - _a.FromJacobian(a) + var pZSquare, aZSquare fptower.E2 + pZSquare.Square(&p.Z) + aZSquare.Square(&a.Z) - return _p.X.Equal(&_a.X) && _p.Y.Equal(&_a.Y) + var lhs, rhs fptower.E2 + lhs.Mul(&p.X, &aZSquare) + rhs.Mul(&a.X, &pZSquare) + if !lhs.Equal(&rhs) { + return false + } + lhs.Mul(&p.Y, &aZSquare).Mul(&lhs, &a.Z) + rhs.Mul(&a.Y, &pZSquare).Mul(&rhs, &p.Z) + + return lhs.Equal(&rhs) } // Neg computes -G @@ -403,8 +416,11 @@ func (p *G2Jac) mulWindowed(a *G2Jac, s *big.Int) *G2Jac { var res G2Jac var ops [3]G2Jac - res.Set(&g2Infinity) ops[0].Set(a) + if s.Sign() == -1 { + ops[0].Neg(&ops[0]) + } + res.Set(&g2Infinity) ops[1].Double(&ops[0]) ops[2].Set(&ops[0]).AddAssign(&ops[1]) diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bls12-377/internal/fptower/e12.go b/vendor/github.com/consensys/gnark-crypto/ecc/bls12-377/internal/fptower/e12.go index d2de48d6b..450562473 100644 --- a/vendor/github.com/consensys/gnark-crypto/ecc/bls12-377/internal/fptower/e12.go +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bls12-377/internal/fptower/e12.go @@ -610,8 +610,14 @@ func (z *E12) ExpGLV(x E12, k *big.Int) *E12 { s1 = s1.SetBigInt(&s[0]).Bits() s2 = s2.SetBigInt(&s[1]).Bits() + maxBit := s1.BitLen() + if s2.BitLen() > maxBit { + maxBit = s2.BitLen() + } + hiWordIndex := (maxBit - 1) / 64 + // loop starts from len(s1)/2 due to the bounds - for i := len(s1) / 2; i >= 0; i-- { + for i := hiWordIndex; i >= 0; i-- { mask := uint64(3) << 62 for j := 0; j < 32; j++ { res.CyclotomicSquare(&res).CyclotomicSquare(&res) diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bls12-381/g1.go b/vendor/github.com/consensys/gnark-crypto/ecc/bls12-381/g1.go index 8eb803c3b..c24a82cda 100644 --- a/vendor/github.com/consensys/gnark-crypto/ecc/bls12-381/g1.go +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bls12-381/g1.go @@ -184,17 +184,30 @@ func (p *G1Jac) Set(a *G1Jac) *G1Jac { // Equal tests if two points (in Jacobian coordinates) are equal func (p *G1Jac) Equal(a *G1Jac) bool { - - if p.Z.IsZero() && a.Z.IsZero() { - return true + // If one point is infinity, the other must also be infinity. + if p.Z.IsZero() { + return a.Z.IsZero() + } + // If the other point is infinity, return false since we can't + // the following checks would be incorrect. + if a.Z.IsZero() { + return false } - _p := G1Affine{} - _p.FromJacobian(p) - _a := G1Affine{} - _a.FromJacobian(a) + var pZSquare, aZSquare fp.Element + pZSquare.Square(&p.Z) + aZSquare.Square(&a.Z) - return _p.X.Equal(&_a.X) && _p.Y.Equal(&_a.Y) + var lhs, rhs fp.Element + lhs.Mul(&p.X, &aZSquare) + rhs.Mul(&a.X, &pZSquare) + if !lhs.Equal(&rhs) { + return false + } + lhs.Mul(&p.Y, &aZSquare).Mul(&lhs, &a.Z) + rhs.Mul(&a.Y, &pZSquare).Mul(&rhs, &p.Z) + + return lhs.Equal(&rhs) } // Neg computes -G @@ -421,8 +434,11 @@ func (p *G1Jac) mulWindowed(a *G1Jac, s *big.Int) *G1Jac { var res G1Jac var ops [3]G1Jac - res.Set(&g1Infinity) ops[0].Set(a) + if s.Sign() == -1 { + ops[0].Neg(&ops[0]) + } + res.Set(&g1Infinity) ops[1].Double(&ops[0]) ops[2].Set(&ops[0]).AddAssign(&ops[1]) diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bls12-381/g2.go b/vendor/github.com/consensys/gnark-crypto/ecc/bls12-381/g2.go index 798337382..cd32bfb46 100644 --- a/vendor/github.com/consensys/gnark-crypto/ecc/bls12-381/g2.go +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bls12-381/g2.go @@ -173,17 +173,30 @@ func (p *G2Jac) Set(a *G2Jac) *G2Jac { // Equal tests if two points (in Jacobian coordinates) are equal func (p *G2Jac) Equal(a *G2Jac) bool { - - if p.Z.IsZero() && a.Z.IsZero() { - return true + // If one point is infinity, the other must also be infinity. + if p.Z.IsZero() { + return a.Z.IsZero() + } + // If the other point is infinity, return false since we can't + // the following checks would be incorrect. + if a.Z.IsZero() { + return false } - _p := G2Affine{} - _p.FromJacobian(p) - _a := G2Affine{} - _a.FromJacobian(a) + var pZSquare, aZSquare fptower.E2 + pZSquare.Square(&p.Z) + aZSquare.Square(&a.Z) - return _p.X.Equal(&_a.X) && _p.Y.Equal(&_a.Y) + var lhs, rhs fptower.E2 + lhs.Mul(&p.X, &aZSquare) + rhs.Mul(&a.X, &pZSquare) + if !lhs.Equal(&rhs) { + return false + } + lhs.Mul(&p.Y, &aZSquare).Mul(&lhs, &a.Z) + rhs.Mul(&a.Y, &pZSquare).Mul(&rhs, &p.Z) + + return lhs.Equal(&rhs) } // Neg computes -G @@ -404,8 +417,11 @@ func (p *G2Jac) mulWindowed(a *G2Jac, s *big.Int) *G2Jac { var res G2Jac var ops [3]G2Jac - res.Set(&g2Infinity) ops[0].Set(a) + if s.Sign() == -1 { + ops[0].Neg(&ops[0]) + } + res.Set(&g2Infinity) ops[1].Double(&ops[0]) ops[2].Set(&ops[0]).AddAssign(&ops[1]) diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bls12-381/internal/fptower/e12.go b/vendor/github.com/consensys/gnark-crypto/ecc/bls12-381/internal/fptower/e12.go index 1ccfa6c70..095a79a4c 100644 --- a/vendor/github.com/consensys/gnark-crypto/ecc/bls12-381/internal/fptower/e12.go +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bls12-381/internal/fptower/e12.go @@ -610,8 +610,14 @@ func (z *E12) ExpGLV(x E12, k *big.Int) *E12 { s1 = s1.SetBigInt(&s[0]).Bits() s2 = s2.SetBigInt(&s[1]).Bits() + maxBit := s1.BitLen() + if s2.BitLen() > maxBit { + maxBit = s2.BitLen() + } + hiWordIndex := (maxBit - 1) / 64 + // loop starts from len(s1)/2 due to the bounds - for i := len(s1) / 2; i >= 0; i-- { + for i := hiWordIndex; i >= 0; i-- { mask := uint64(3) << 62 for j := 0; j < 32; j++ { res.CyclotomicSquare(&res).CyclotomicSquare(&res) diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/g1.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/g1.go index c03823d25..e64b53ffa 100644 --- a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/g1.go +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/g1.go @@ -184,17 +184,30 @@ func (p *G1Jac) Set(a *G1Jac) *G1Jac { // Equal tests if two points (in Jacobian coordinates) are equal func (p *G1Jac) Equal(a *G1Jac) bool { - - if p.Z.IsZero() && a.Z.IsZero() { - return true + // If one point is infinity, the other must also be infinity. + if p.Z.IsZero() { + return a.Z.IsZero() + } + // If the other point is infinity, return false since we can't + // the following checks would be incorrect. + if a.Z.IsZero() { + return false } - _p := G1Affine{} - _p.FromJacobian(p) - _a := G1Affine{} - _a.FromJacobian(a) + var pZSquare, aZSquare fp.Element + pZSquare.Square(&p.Z) + aZSquare.Square(&a.Z) - return _p.X.Equal(&_a.X) && _p.Y.Equal(&_a.Y) + var lhs, rhs fp.Element + lhs.Mul(&p.X, &aZSquare) + rhs.Mul(&a.X, &pZSquare) + if !lhs.Equal(&rhs) { + return false + } + lhs.Mul(&p.Y, &aZSquare).Mul(&lhs, &a.Z) + rhs.Mul(&a.Y, &pZSquare).Mul(&rhs, &p.Z) + + return lhs.Equal(&rhs) } // Neg computes -G @@ -411,8 +424,11 @@ func (p *G1Jac) mulWindowed(a *G1Jac, s *big.Int) *G1Jac { var res G1Jac var ops [3]G1Jac - res.Set(&g1Infinity) ops[0].Set(a) + if s.Sign() == -1 { + ops[0].Neg(&ops[0]) + } + res.Set(&g1Infinity) ops[1].Double(&ops[0]) ops[2].Set(&ops[0]).AddAssign(&ops[1]) diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/g2.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/g2.go index bb57fe175..b4f279fc3 100644 --- a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/g2.go +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/g2.go @@ -173,17 +173,30 @@ func (p *G2Jac) Set(a *G2Jac) *G2Jac { // Equal tests if two points (in Jacobian coordinates) are equal func (p *G2Jac) Equal(a *G2Jac) bool { - - if p.Z.IsZero() && a.Z.IsZero() { - return true + // If one point is infinity, the other must also be infinity. + if p.Z.IsZero() { + return a.Z.IsZero() + } + // If the other point is infinity, return false since we can't + // the following checks would be incorrect. + if a.Z.IsZero() { + return false } - _p := G2Affine{} - _p.FromJacobian(p) - _a := G2Affine{} - _a.FromJacobian(a) + var pZSquare, aZSquare fptower.E2 + pZSquare.Square(&p.Z) + aZSquare.Square(&a.Z) - return _p.X.Equal(&_a.X) && _p.Y.Equal(&_a.Y) + var lhs, rhs fptower.E2 + lhs.Mul(&p.X, &aZSquare) + rhs.Mul(&a.X, &pZSquare) + if !lhs.Equal(&rhs) { + return false + } + lhs.Mul(&p.Y, &aZSquare).Mul(&lhs, &a.Z) + rhs.Mul(&a.Y, &pZSquare).Mul(&rhs, &p.Z) + + return lhs.Equal(&rhs) } // Neg computes -G @@ -410,8 +423,11 @@ func (p *G2Jac) mulWindowed(a *G2Jac, s *big.Int) *G2Jac { var res G2Jac var ops [3]G2Jac - res.Set(&g2Infinity) ops[0].Set(a) + if s.Sign() == -1 { + ops[0].Neg(&ops[0]) + } + res.Set(&g2Infinity) ops[1].Double(&ops[0]) ops[2].Set(&ops[0]).AddAssign(&ops[1]) diff --git a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e12.go b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e12.go index 29093174b..a9f6d28e9 100644 --- a/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e12.go +++ b/vendor/github.com/consensys/gnark-crypto/ecc/bn254/internal/fptower/e12.go @@ -610,8 +610,14 @@ func (z *E12) ExpGLV(x E12, k *big.Int) *E12 { s1 = s1.SetBigInt(&s[0]).Bits() s2 = s2.SetBigInt(&s[1]).Bits() + maxBit := s1.BitLen() + if s2.BitLen() > maxBit { + maxBit = s2.BitLen() + } + hiWordIndex := (maxBit - 1) / 64 + // loop starts from len(s1)/2 due to the bounds - for i := len(s1) / 2; i >= 0; i-- { + for i := hiWordIndex; i >= 0; i-- { mask := uint64(3) << 62 for j := 0; j < 32; j++ { res.CyclotomicSquare(&res).CyclotomicSquare(&res) diff --git a/vendor/modules.txt b/vendor/modules.txt index ae23ff147..24b5f3ef5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -54,7 +54,7 @@ github.com/cloudflare/cfssl/signer/universal # github.com/consensys/bavard v0.1.13 ## explicit; go 1.15 github.com/consensys/bavard -# github.com/consensys/gnark-crypto v0.12.0 +# github.com/consensys/gnark-crypto v0.12.1 ## explicit; go 1.18 github.com/consensys/gnark-crypto/ecc github.com/consensys/gnark-crypto/ecc/bls12-377