Beispiel #1
0
 def test_ecc_sanity(self):
     G = ecc.generator()
     n = G.order()
     self.assertEqual(ecc.CURVE_ORDER, n)
     inf = n * G
     self.assertEqual(ecc.point_at_infinity(), inf)
     self.assertTrue(inf.is_at_infinity())
     self.assertFalse(G.is_at_infinity())
     self.assertEqual(11 * G, 7 * G + 4 * G)
     self.assertEqual((n + 2) * G, 2 * G)
     self.assertEqual((n - 2) * G, -2 * G)
     A = (n - 2) * G
     B = (n - 1) * G
     C = n * G
     D = (n + 1) * G
     self.assertFalse(A.is_at_infinity())
     self.assertFalse(B.is_at_infinity())
     self.assertTrue(C.is_at_infinity())
     self.assertTrue((C * 5).is_at_infinity())
     self.assertFalse(D.is_at_infinity())
     self.assertEqual(inf, C)
     self.assertEqual(inf, A + 2 * G)
     self.assertEqual(inf, D + (-1) * G)
     self.assertNotEqual(A, B)
Beispiel #2
0
 def test_ecc_sanity(self):
     G = ecc.generator()
     n = G.order()
     self.assertEqual(ecc.CURVE_ORDER, n)
     inf = n * G
     self.assertEqual(ecc.point_at_infinity(), inf)
     self.assertTrue(inf.is_at_infinity())
     self.assertFalse(G.is_at_infinity())
     self.assertEqual(11 * G, 7 * G + 4 * G)
     self.assertEqual((n + 2) * G, 2 * G)
     self.assertEqual((n - 2) * G, -2 * G)
     A = (n - 2) * G
     B = (n - 1) * G
     C = n * G
     D = (n + 1) * G
     self.assertFalse(A.is_at_infinity())
     self.assertFalse(B.is_at_infinity())
     self.assertTrue(C.is_at_infinity())
     self.assertTrue((C * 5).is_at_infinity())
     self.assertFalse(D.is_at_infinity())
     self.assertEqual(inf, C)
     self.assertEqual(inf, A + 2 * G)
     self.assertEqual(inf, D + (-1) * G)
     self.assertNotEqual(A, B)