from CryptoAttacks.EllipticCurve.pohlig_hellman_sage import pohlig_hellman


def test_ph():
    M = 93556643250795678718734474880013829509320385402690660619699653921022012489089
    A = 66001598144012865876674115570268990806314506711104521036747533612798434904785
    B = 25255205054024371783896605039267101837972419055969636393425590261926131199030
    Pt = (56027910981442853390816693056740903416379421186644480759538594137486160388926, 65533262933617146434438829354623658858649726233622196512439589744498050226926)
    Qt = (34492003315901643516027214681643546054021626043941009296234139428306204273023, 28634523416511300194166707350048820787265085824285526555863582510484829614250)
    n_max = 400000000000000000000000000000

    n = pohlig_hellman(A, B, M, Pt, Qt, P_order_factors=None, n_max=n_max)
    print n

    E = EllipticCurve(GF(M), [A,B])
    P = E(Pt)
    Q = E(Qt)
    assert Q == n*P


if __name__ == "__main__":
    test_ph()
