Skip to content

Commit

Permalink
bw6761: test mul 01 by 01
Browse files Browse the repository at this point in the history
  • Loading branch information
shramee committed Mar 8, 2024
1 parent 10215c6 commit 426e330
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions std/algebra/emulated/fields_bw6761/e3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,49 @@ func TestMulFp3(t *testing.T) {
assert.NoError(err)
}

type e3Mul01By01 struct {
A0, A1 baseEl
B0, B1 baseEl
C E3
}

func (circuit *e3Mul01By01) Define(api frontend.API) error {
e := NewExt3(api)
expected := e.Mul01By01(&circuit.A0, &circuit.A1, &circuit.B0, &circuit.B1)
e.AssertIsEqual(expected, &circuit.C)

return nil
}

func TestMul01By01(t *testing.T) {

assert := test.NewAssert(t)
// witness values
var a, c bw6761.E3
var A0, A1, B0, B1 fp.Element
A0.SetRandom()
A1.SetRandom()
B0.SetRandom()
B1.SetRandom()
a.A0 = A0
a.A1 = A1
a.A2.SetZero()
c.Set(&a)
c.MulBy01(&B0, &B1)

witness := e3Mul01By01{
A0: emulated.ValueOf[emulated.BW6761Fp](A0),
A1: emulated.ValueOf[emulated.BW6761Fp](A1),
B0: emulated.ValueOf[emulated.BW6761Fp](B0),
B1: emulated.ValueOf[emulated.BW6761Fp](B1),
C: FromE3(&c),
}

err := test.IsSolved(&e3Mul01By01{}, &witness, ecc.BN254.ScalarField())
assert.NoError(err)

}

type e3MulByNonResidue struct {
A, B E3
}
Expand Down

0 comments on commit 426e330

Please sign in to comment.