Skip to content

Commit

Permalink
Merge pull request #514 from Consensys/refactor/bw6-conj
Browse files Browse the repository at this point in the history
refactor: remove E3 Conjugate from BW6
  • Loading branch information
ThomasPiellard committed Jul 1, 2024
2 parents 1ef1276 + f230a0d commit f7d26b6
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 121 deletions.
8 changes: 0 additions & 8 deletions ecc/bw6-633/internal/fptower/e3.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,6 @@ func (z *E3) String() string {
return (z.A0.String() + "+(" + z.A1.String() + ")*u+(" + z.A2.String() + ")*u**2")
}

// Conjugate conjugates an element in E3
func (z *E3) Conjugate(x *E3) *E3 {
z.A0.Set(&x.A0)
z.A1.Neg(&x.A1)
z.A2.Set(&x.A2)
return z
}

// MulByElement multiplies an element in E3 by an element in fp
func (z *E3) MulByElement(x *E3, y *fp.Element) *E3 {
var yCopy fp.Element
Expand Down
33 changes: 0 additions & 33 deletions ecc/bw6-633/internal/fptower/e3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,6 @@ func TestE3ReceiverIsOperand(t *testing.T) {
genA,
))

properties.Property("[BW6-633] Having the receiver as operand (Conjugate) should output the same result", prop.ForAll(
func(a *E3) bool {
var b E3
b.Conjugate(a)
a.Conjugate(a)
return a.Equal(&b)
},
genA,
))

properties.Property("[BW6-633] Having the receiver as operand (mul by element) should output the same result", prop.ForAll(
func(a *E3, b fp.Element) bool {
var c E3
Expand Down Expand Up @@ -246,20 +236,6 @@ func TestE3Ops(t *testing.T) {
genA,
))

properties.Property("[BW6-633] a + pi(a), a-pi(a) should be real", prop.ForAll(
func(a *E3) bool {
var b, c, d E3
var e, f fp.Element
b.Conjugate(a)
c.Add(a, &b)
d.Sub(a, &b)
e.Double(&a.A0)
f.Double(&a.A1)
return c.A1.IsZero() && d.A0.IsZero() && e.Equal(&c.A0) && f.Equal(&d.A1)
},
genA,
))

properties.TestingRun(t, gopter.ConsoleReporter(false))
}

Expand Down Expand Up @@ -333,12 +309,3 @@ func BenchmarkE3MulNonRes(b *testing.B) {
a.MulByNonResidue(&a)
}
}

func BenchmarkE3Conjugate(b *testing.B) {
var a E3
_, _ = a.SetRandom()
b.ResetTimer()
for i := 0; i < b.N; i++ {
a.Conjugate(&a)
}
}
7 changes: 0 additions & 7 deletions ecc/bw6-756/internal/fptower/e3.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,6 @@ func (z *E3) String() string {
return (z.A0.String() + "+(" + z.A1.String() + ")*u+(" + z.A2.String() + ")*u**2")
}

// Conjugate conjugates an element in E3
func (z *E3) Conjugate(x *E3) *E3 {
*z = *x
z.A1.Neg(&z.A1)
return z
}

// MulByElement multiplies an element in E3 by an element in fp
func (z *E3) MulByElement(x *E3, y *fp.Element) *E3 {
_y := *y
Expand Down
33 changes: 0 additions & 33 deletions ecc/bw6-756/internal/fptower/e3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,6 @@ func TestE3ReceiverIsOperand(t *testing.T) {
genA,
))

properties.Property("[BW756] Having the receiver as operand (Conjugate) should output the same result", prop.ForAll(
func(a *E3) bool {
var b E3
b.Conjugate(a)
a.Conjugate(a)
return a.Equal(&b)
},
genA,
))

properties.Property("[BW756] Having the receiver as operand (mul by element) should output the same result", prop.ForAll(
func(a *E3, b fp.Element) bool {
var c E3
Expand Down Expand Up @@ -248,20 +238,6 @@ func TestE3Ops(t *testing.T) {
genA,
))

properties.Property("[BW756] a + pi(a), a-pi(a) should be real", prop.ForAll(
func(a *E3) bool {
var b, c, d E3
var e, f fp.Element
b.Conjugate(a)
c.Add(a, &b)
d.Sub(a, &b)
e.Double(&a.A0)
f.Double(&a.A1)
return c.A1.IsZero() && d.A0.IsZero() && e.Equal(&c.A0) && f.Equal(&d.A1)
},
genA,
))

properties.TestingRun(t, gopter.ConsoleReporter(false))
}

Expand Down Expand Up @@ -335,12 +311,3 @@ func BenchmarkE3MulNonRes(b *testing.B) {
a.MulByNonResidue(&a)
}
}

func BenchmarkE3Conjugate(b *testing.B) {
var a E3
_, _ = a.SetRandom()
b.ResetTimer()
for i := 0; i < b.N; i++ {
a.Conjugate(&a)
}
}
7 changes: 0 additions & 7 deletions ecc/bw6-761/internal/fptower/e3.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,6 @@ func (z *E3) String() string {
return (z.A0.String() + "+(" + z.A1.String() + ")*u+(" + z.A2.String() + ")*u**2")
}

// Conjugate conjugates an element in E3
func (z *E3) Conjugate(x *E3) *E3 {
*z = *x
z.A1.Neg(&z.A1)
return z
}

// MulByElement multiplies an element in E3 by an element in fp
func (z *E3) MulByElement(x *E3, y *fp.Element) *E3 {
_y := *y
Expand Down
33 changes: 0 additions & 33 deletions ecc/bw6-761/internal/fptower/e3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,6 @@ func TestE3ReceiverIsOperand(t *testing.T) {
genA,
))

properties.Property("[BW761] Having the receiver as operand (Conjugate) should output the same result", prop.ForAll(
func(a *E3) bool {
var b E3
b.Conjugate(a)
a.Conjugate(a)
return a.Equal(&b)
},
genA,
))

properties.Property("[BW761] Having the receiver as operand (mul by element) should output the same result", prop.ForAll(
func(a *E3, b fp.Element) bool {
var c E3
Expand Down Expand Up @@ -246,20 +236,6 @@ func TestE3Ops(t *testing.T) {
genA,
))

properties.Property("[BW761] a + pi(a), a-pi(a) should be real", prop.ForAll(
func(a *E3) bool {
var b, c, d E3
var e, f fp.Element
b.Conjugate(a)
c.Add(a, &b)
d.Sub(a, &b)
e.Double(&a.A0)
f.Double(&a.A1)
return c.A1.IsZero() && d.A0.IsZero() && e.Equal(&c.A0) && f.Equal(&d.A1)
},
genA,
))

properties.TestingRun(t, gopter.ConsoleReporter(false))
}

Expand Down Expand Up @@ -333,12 +309,3 @@ func BenchmarkE3MulNonRes(b *testing.B) {
a.MulByNonResidue(&a)
}
}

func BenchmarkE3Conjugate(b *testing.B) {
var a E3
_, _ = a.SetRandom()
b.ResetTimer()
for i := 0; i < b.N; i++ {
a.Conjugate(&a)
}
}

0 comments on commit f7d26b6

Please sign in to comment.