File tree Expand file tree Collapse file tree 2 files changed +4
-11
lines changed Expand file tree Collapse file tree 2 files changed +4
-11
lines changed Original file line number Diff line number Diff line change 5
5
"math/big"
6
6
7
7
"github.com/consensys/gnark-crypto/ecc/bn254"
8
+ "github.com/ethereum/go-ethereum/common/bitutil"
8
9
)
9
10
10
11
// G1 is the affine representation of a G1 group element.
@@ -43,7 +44,7 @@ func (g *G1) Unmarshal(buf []byte) (int, error) {
43
44
return 0 , errors .New ("invalid G1 point size" )
44
45
}
45
46
46
- if allZeroes (buf [:64 ]) {
47
+ if ! bitutil . TestBytes (buf [:64 ]) {
47
48
// point at infinity
48
49
g .inner .X .SetZero ()
49
50
g .inner .Y .SetZero ()
@@ -82,12 +83,3 @@ func (p *G1) Marshal() []byte {
82
83
83
84
return output
84
85
}
85
-
86
- func allZeroes (buf []byte ) bool {
87
- for i := range buf {
88
- if buf [i ] != 0 {
89
- return false
90
- }
91
- }
92
- return true
93
- }
Original file line number Diff line number Diff line change 4
4
"errors"
5
5
6
6
"github.com/consensys/gnark-crypto/ecc/bn254"
7
+ "github.com/ethereum/go-ethereum/common/bitutil"
7
8
)
8
9
9
10
// G2 is the affine representation of a G2 group element.
@@ -31,7 +32,7 @@ func (g *G2) Unmarshal(buf []byte) (int, error) {
31
32
return 0 , errors .New ("invalid G2 point size" )
32
33
}
33
34
34
- if allZeroes (buf [:128 ]) {
35
+ if ! bitutil . TestBytes (buf [:128 ]) {
35
36
// point at infinity
36
37
g .inner .X .A0 .SetZero ()
37
38
g .inner .X .A1 .SetZero ()
You can’t perform that action at this time.
0 commit comments