Skip to content

Commit

Permalink
Merge pull request #410 from dedis/bn256-addmul-test
Browse files Browse the repository at this point in the history
pairing/bn256: test for add/mul consistency
  • Loading branch information
Jeff R. Allen authored Jan 9, 2020
2 parents a5a2914 + 019907a commit 406d4f5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pairing/bn256/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,18 @@ func basicPointTest(t *testing.T, s *Suite) {
err = paCopy.UnmarshalBinary(paBuf)
require.Nil(t, err)
require.True(t, pa.Equal(paCopy))

const addersTarget = 123
scalarUnit := s.Scalar().One()
pointUnit := s.Point().Mul(scalarUnit, nil)

scalarAdder := s.Scalar().Zero()
pointAdder := s.Point().Mul(scalarAdder, nil)
for i := 0; i < addersTarget; i++ {
scalarAdder.Add(scalarAdder, scalarUnit)
pointAdder.Add(pointAdder, pointUnit)
}
require.True(t, pointAdder.Equal(s.Point().Mul(scalarAdder, nil)))
}

// Test that the suite.Read works correctly for suites with a defined `Point()`.
Expand Down

0 comments on commit 406d4f5

Please sign in to comment.