diff --git a/tests/polys/test_arithmetic.py b/tests/polys/test_arithmetic.py index 8accade30..a498d0fa8 100644 --- a/tests/polys/test_arithmetic.py +++ b/tests/polys/test_arithmetic.py @@ -277,6 +277,29 @@ def test_modular_power_large_exponent_python(): ) +def test_issue_575(): + """ + See https://github.com/mhostetter/galois/issues/575. + """ + p = 2**127 - 1 + coeffs = [132937, -281708, 210865, -132177, 154492, -119403, 64244, -21729, 12062, -425, 325, 525, 110, 20, 4, 1, 1] + GF = galois.GF(p) + f = galois.Poly(coeffs[::-1], GF) + x = galois.Poly([1, 0], field=GF) + assert pow(x, 2**127, f) == galois.Poly.Str( + "126874514830231536187056856301640158266*x^15 + 88670945103773467760645459899285914743*x^14 + 44780008662049372376206359379944471593*x^13 + 33818881572206493584109676427588035387*x^12 + 134546675937580697147194446965861675646*x^11 + 151205053658499456383273529253793414759*x^10 + 102575528654422663211099361243810661503*x^9 + 105139384602691190152831210775115177423*x^8 + 136407756294582872557207549237534950566*x^7 + 140945995299106154327513609896836473518*x^6 + 158922593026029631006872698384116782258*x^5 + 110784094448807401197356074527405807846*x^4 + 118135528423017478604752208093185023497*x^3 + 12607999635247244488159299210050515125*x^2 + 29239737560904480764966103643054964577*x + 126180525539554453884712904518400485917", + field=GF, + ) + assert pow(x, 2**127 - 1, f) == galois.Poly.Str( + "61021651652182409301257243964924136068*x^15 + 17754983021944713756626796550680188607*x^14 + 162616368252033873233987132043098353288*x^13 + 74224757482412936279540112667238452864*x^12 + 110694408353971479186601667649762879514*x^11 + 14230119304660783018347126248937128943*x^10 + 76723375742882366684463283095697266800*x^9 + 29833462468221933393240840965436903107*x^8 + 117541963237015710638432040775403054637*x^7 + 107181713459734050577711293285818259505*x^6 + 22785441973771742759042671081469864576*x^5 + 116690878624191510765265883568441507902*x^4 + 114956782273924149969679110164620997959*x^3 + 2087041452633506962649307801683951896*x^2 + 75902072172396381781189841770738678116*x + 126408216528042284947701470861037753605", + field=GF, + ) + assert pow(x, 2**127 - 2, f) == galois.Poly.Str( + "97661575619289570424072420644193169832*x^15 + 158683227271471979725329664609117305900*x^14 + 68118918578164531989541871695684656481*x^13 + 74153679112194500935187900336352481204*x^12 + 98103517594704083831206249427788473583*x^11 + 384203419287968855056783654177111760*x^10 + 107982071926494068748045344457273659121*x^9 + 85002501899307478985386615989321885588*x^8 + 136345485510529110083575026157787468670*x^7 + 30005450666198123572855807608582402253*x^6 + 151164510835507036985291331889538157661*x^5 + 74103785581398823624222571749250731406*x^4 + 98823362957504732263269825373023428613*x^3 + 112465297236985690465068546771113621185*x^2 + 31807498133499870757448586129935697677*x + 28264254681331602756413169577031806687", + field=GF, + ) + + def test_evaluate_constant(poly_evaluate): GF, X, Y, Z = poly_evaluate["GF"], poly_evaluate["X"], poly_evaluate["Y"], poly_evaluate["Z"] for i in range(len(X)):