Esempio n. 1
0
 def test_parameter_recovery(self):
     p = 115792089210356248762697446949407573530086143415290314195533631308867097853951
     a = 115792089210356248762697446949407573530086143415290314195533631308867097853948
     b = 41058363725152142129326129780047268409114441015993725554835256314039467401291
     p_256 = EllipticCurve(GF(p), [a, b])
     x1, y1 = p_256.random_point().xy()
     x2, y2 = p_256.random_point().xy()
     a_, b_ = self.parameter_recovery.attack(p, x1, y1, x2, y2)
     self.assertIsInstance(a_, int)
     self.assertIsInstance(b_, int)
     self.assertEqual(a, a_)
     self.assertEqual(b, b_)
Esempio n. 2
0
            56294930529307888037266989938554520078909974976727867290405186147804672857970,
            40227799284408618946039395270241596338545732655219360714266457471089156305972,
            1)
    k = random.randint(0, E[0])

    P = point_mult(P, k, E)

    return P


if __name__ == '__main__':
    E = EllipticCurve(GF(p), [A, B])
    P = E(G[0], G[1])

    # in sage every point in standart projective coord, we need to move it to jacobian
    # all comutation in chudnovskiy and jcaoban coord, but input|output in sage-projective

    sage_rand_P = E.random_point()

    # newR = get_random_point(E)

    # print(is_inf(P))
    # print(is_on_curve(P, E))
    print(point_double(P, E))
    print(point_add(P, sage_rand_P, E))
    print(point_mult(P, 11, E))
    # print(F"New random point {newR} is on curve: {is_on_curve(newR, E)}")

    print(F"old: {point_mult(sage_rand_P, 46237, E)}")
    print(F"new: {point_mult_cool_algo(sage_rand_P, 46237, 4, E)}")