appease felix

This commit is contained in:
Kevaundray Wedderburn 2025-06-17 15:09:08 +02:00
parent 283f1a10d1
commit 103d398e48
3 changed files with 15 additions and 20 deletions

View file

@ -44,13 +44,7 @@ func (g *G1) Unmarshal(buf []byte) (int, error) {
} }
// Check if both coordinates are zero (point at infinity) // Check if both coordinates are zero (point at infinity)
isZero := true isZero := allZeroes(buf[0:64])
for i := 0; i < 64; i++ {
if buf[i] != 0 {
isZero = false
break
}
}
if isZero { if isZero {
g.inner.X.SetZero() g.inner.X.SetZero()
g.inner.Y.SetZero() g.inner.Y.SetZero()
@ -97,3 +91,14 @@ func (p *G1) Marshal() []byte {
return output 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
}

View file

@ -32,13 +32,7 @@ func (g *G2) Unmarshal(buf []byte) (int, error) {
} }
// Check if all coordinates are zero (point at infinity) // Check if all coordinates are zero (point at infinity)
isZero := true isZero := allZeroes(buf[0:128])
for i := 0; i < 128; i++ {
if buf[i] != 0 {
isZero = false
break
}
}
if isZero { if isZero {
g.inner.X.A0.SetZero() g.inner.X.A0.SetZero()
g.inner.X.A1.SetZero() g.inner.X.A1.SetZero()

View file

@ -21,14 +21,10 @@ func TestNativeGnarkFormatIncompatibility(t *testing.T) {
func TestSerRoundTrip(t *testing.T) { func TestSerRoundTrip(t *testing.T) {
_, _, g1Gen, g2Gen := bn254.Generators() _, _, g1Gen, g2Gen := bn254.Generators()
expectedG1 := G1{ expectedG1 := G1{inner: g1Gen}
inner: g1Gen,
}
bytesG1 := expectedG1.Marshal() bytesG1 := expectedG1.Marshal()
expectedG2 := G2{ expectedG2 := G2{inner: g2Gen}
inner: g2Gen,
}
bytesG2 := expectedG2.Marshal() bytesG2 := expectedG2.Marshal()
var gotG1 G1 var gotG1 G1