Beispiel #1
0
 def on_curve(self, point):
     lhs = NumberTheory.binpoly_reduce(
         NumberTheory.cl_mul(point.y, point.y)
         ^ NumberTheory.cl_mul(point.x, point.y), self.intpoly)
     rhs = NumberTheory.binpoly_reduce(
         NumberTheory.cl_mul(NumberTheory.cl_mul(point.x, point.x), point.x)
         ^ NumberTheory.cl_mul(NumberTheory.cl_mul(self.a, point.x),
                               point.x) ^ self.b, self.intpoly)
     return lhs == rhs
Beispiel #2
0
 def test_polynomial_reduction(self):
     self.assertEqual(NumberTheory.binpoly_reduce(0, 0x10001), 0)
     self.assertEqual(NumberTheory.binpoly_reduce(0x123, 0x10001), 0x123)
     self.assertEqual(NumberTheory.binpoly_reduce(0x1234, 0x10001), 0x1234)
     self.assertEqual(NumberTheory.binpoly_reduce(0x12345, 0x10001), 0x2344)
     self.assertEqual(NumberTheory.binpoly_reduce(0x20000, 0x10001), 0x2)