mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
Co-authored-by: cui <cuiweixie@gmail.com>
This commit is contained in:
parent
57612d9826
commit
c7f17cb300
2 changed files with 4 additions and 11 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"errors"
|
||||
"math/big"
|
||||
|
||||
"github.com/XinFinOrg/XDPoSChain/common/bitutil"
|
||||
"github.com/consensys/gnark-crypto/ecc/bn254"
|
||||
)
|
||||
|
||||
|
|
@ -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()
|
||||
|
|
@ -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,6 +3,7 @@ package bn256
|
|||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/XinFinOrg/XDPoSChain/common/bitutil"
|
||||
"github.com/consensys/gnark-crypto/ecc/bn254"
|
||||
)
|
||||
|
||||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue