mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
appease felix
This commit is contained in:
parent
283f1a10d1
commit
103d398e48
3 changed files with 15 additions and 20 deletions
|
|
@ -44,13 +44,7 @@ func (g *G1) Unmarshal(buf []byte) (int, error) {
|
|||
}
|
||||
|
||||
// Check if both coordinates are zero (point at infinity)
|
||||
isZero := true
|
||||
for i := 0; i < 64; i++ {
|
||||
if buf[i] != 0 {
|
||||
isZero = false
|
||||
break
|
||||
}
|
||||
}
|
||||
isZero := allZeroes(buf[0:64])
|
||||
if isZero {
|
||||
g.inner.X.SetZero()
|
||||
g.inner.Y.SetZero()
|
||||
|
|
@ -97,3 +91,14 @@ func (p *G1) Marshal() []byte {
|
|||
|
||||
return output
|
||||
}
|
||||
|
||||
func allZeroes(buf []byte) bool {
|
||||
isZero := true
|
||||
for i := 0; i < len(buf); i++ {
|
||||
if buf[i] != 0 {
|
||||
isZero = false
|
||||
break
|
||||
}
|
||||
}
|
||||
return isZero
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,13 +32,7 @@ func (g *G2) Unmarshal(buf []byte) (int, error) {
|
|||
}
|
||||
|
||||
// Check if all coordinates are zero (point at infinity)
|
||||
isZero := true
|
||||
for i := 0; i < 128; i++ {
|
||||
if buf[i] != 0 {
|
||||
isZero = false
|
||||
break
|
||||
}
|
||||
}
|
||||
isZero := allZeroes(buf[0:128])
|
||||
if isZero {
|
||||
g.inner.X.A0.SetZero()
|
||||
g.inner.X.A1.SetZero()
|
||||
|
|
|
|||
|
|
@ -21,14 +21,10 @@ func TestNativeGnarkFormatIncompatibility(t *testing.T) {
|
|||
func TestSerRoundTrip(t *testing.T) {
|
||||
_, _, g1Gen, g2Gen := bn254.Generators()
|
||||
|
||||
expectedG1 := G1{
|
||||
inner: g1Gen,
|
||||
}
|
||||
expectedG1 := G1{inner: g1Gen}
|
||||
bytesG1 := expectedG1.Marshal()
|
||||
|
||||
expectedG2 := G2{
|
||||
inner: g2Gen,
|
||||
}
|
||||
expectedG2 := G2{inner: g2Gen}
|
||||
bytesG2 := expectedG2.Marshal()
|
||||
|
||||
var gotG1 G1
|
||||
|
|
|
|||
Loading…
Reference in a new issue