Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions crypto/bn256/gnark/g1.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"math/big"

"github.com/consensys/gnark-crypto/ecc/bn254"
"github.com/ethereum/go-ethereum/common/bitutil"
)

// G1 is the affine representation of a G1 group element.
Expand Down Expand Up @@ -43,7 +44,7 @@ func (g *G1) Unmarshal(buf []byte) (int, error) {
return 0, errors.New("invalid G1 point size")
}

if allZeroes(buf[:64]) {
if !bitutil.TestBytes(buf[:64]) {
// point at infinity
g.inner.X.SetZero()
g.inner.Y.SetZero()
Expand Down Expand Up @@ -82,12 +83,3 @@ func (p *G1) Marshal() []byte {

return output
}

func allZeroes(buf []byte) bool {
for i := range buf {
if buf[i] != 0 {
return false
}
}
return true
}
3 changes: 2 additions & 1 deletion crypto/bn256/gnark/g2.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"

"github.com/consensys/gnark-crypto/ecc/bn254"
"github.com/ethereum/go-ethereum/common/bitutil"
)

// G2 is the affine representation of a G2 group element.
Expand Down Expand Up @@ -31,7 +32,7 @@ func (g *G2) Unmarshal(buf []byte) (int, error) {
return 0, errors.New("invalid G2 point size")
}

if allZeroes(buf[:128]) {
if !bitutil.TestBytes(buf[:128]) {
// point at infinity
g.inner.X.A0.SetZero()
g.inner.X.A1.SetZero()
Expand Down
Loading