예제 #1
0
 def test_scalar_mul_ed25519(self):
     curve = CurveDB().instantiate(name="ed25519")
     self.assertEqual(curve.G.scalar_mul(0), curve.point(0, 1))
     self.assertEqual(curve.G.scalar_mul(1), curve.G)
     self.assertEqual(
         curve.G,
         curve.point(
             0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a,
             0x6666666666666666666666666666666666666666666666666666666666666658
         ))
     self.assertEqual(
         curve.G.scalar_mul(2),
         curve.point(
             0x36ab384c9f5a046c3d043b7d1833e7ac080d8e4515d7a45f83c5a14e2843ce0e,
             0x2260cdf3092329c21da25ee8c9a21f5697390f51643851560e5f46ae6af8a3c9
         ))
     self.assertEqual(
         curve.G.scalar_mul(3),
         curve.point(
             0x67ae9c4a22928f491ff4ae743edac83a6343981981624886ac62485fd3f8e25c,
             0x1267b1d177ee69aba126a18e60269ef79f16ec176724030402c3684878f5b4d4
         ))
     self.assertEqual(
         curve.G.scalar_mul(123456789),
         curve.point(
             0x547df969eeaad777ccc47f172eb04d76d148ac6fe7e6f03c5f764f1e15327545,
             0x5bd3c1a4f2053b458e38123b41e36ddeb5d13a6f63365d93e90ddc6880adff17
         ))
예제 #2
0
 def test_fp_point_add_neutral(self):
     curve = CurveDB().instantiate(name="secp112r1")
     Q = curve.point(0x9487239995a5ee76b55f9c2f098,
                     0x32df450fdbbe9dc44268aeb5ab8b)
     self.assertTrue(Q.on_curve())
     P = curve.point_addition(curve.G, Q)
     self.assertEqual(P, curve.neutral_point)
예제 #3
0
 def test_fp_point_add(self):
     curve = CurveDB().instantiate(name="secp112r1")
     Q = curve.point(0x123, 0x84bdce9a00a1895369a805a6c44e)
     self.assertTrue(Q.on_curve())
     P = curve.point_addition(curve.G, Q)
     self.assertEqual(P.x, 0xbbabcf20193b825046cb2357bb87)
     self.assertEqual(P.y, 0x5625e546a0459574b5eff88d17b9)
예제 #4
0
 def test_ed448_generator(self):
     curve = CurveDB().instantiate(name="ed448")
     rfc_8032_G = curve.point(
         224580040295924300187604334099896036246789641632564134246125461686950415467406032909029192869357953282578032075146446173674602635247710,
         298819210078481492676017930443930673437544040154080242095928241372331506189835876003536878655418784733982303233503462500531545062832660
     )
     self.assertTrue(rfc_8032_G.on_curve())
     self.assertEqual(curve.G, rfc_8032_G)