This repository has been archived by the owner on Jun 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
solve.py
23 lines (18 loc) · 2.76 KB
/
solve.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from sage.all import *
h = 413375237866050835502804732043486308981949713955370958845427731233940607141858207757550880255199235686851472338866304024743142898941922631974354348916420780484879331347904704238387832425487522460342290710138051949933310883189102720469133607987057996467293947554380589119829238750094781848170350130497831801611217876942989092345719764200314898669158102244313730975230931112544009145057856521675742950861388173874791039528568561558895815181579301858364138259362829921058326806240384111765338279670560260054563353427754460528603890539615366139305603582265604372575994225735215383986321750393377841593937862153160185645342133606509508520001571229518223836275752518525433558701076039891192814261398659500562164350190829945761692006104635898641478572073212863073125631621497971299672675022001288626707463256073252138701481967062407743806557596369041308983889047934705255485318852853431342862337849731363520248118410793210185350371827359068858393559841913798448034829672746892253550420345882163179831152650968476259967303231679729822898248728387087450741992843049662497263154690695104455477974237146069472299401316797931311120659852648851857194140387033257858969039129859933157153667525509419845028733413050453487438454135759093354594130674
q = 607742205232799657108325196163989360021436966873675254849683716604816556015432478007424579008666585171503163536263245286004822521255112973376081474387798806935082859873359269613813935227747950471728191266717482299248936808191853669670049043912359517061945181569490676109213849905687401754349624084307152017407199998785555263612944449019180507788995303165698279295126097779108218344824633592840592565548119746099221202796432648535712249850651091951655790394099430414062804493560580019822983813169568834558985555437153629719633933320330884220793735585752584969100953721743080669390351307978862760815396651606209673667893784818074332022831190013995799164772221569515395999981137208890121636004883046287147928565447807487257049979756505163502201892799533598161744621624860995682910520061654213884734525345446894716441937387262279317982022457619870643460996902140957200621281728550098731343176236034633425403204499649671051247455319870934916010298565743167394791550162720592434476183528892277527890382162234791497490827083580436090637043916443658730047166767996394046991178244942775140809836211951676812042275080782214688749936371834442869921262629996326457161949367575965694593739827094792458379976830945078430012765866843021472790684957
M = matrix(ZZ, [
[1, h],
[0, q],
])
B = M.LLL()
f, g = B[0]
f, g = abs(f), abs(g)
from Crypto.Util.number import *
def decrypt(enc,f,g,h,q):
f,g,h,q = int(f), int(g), int(h), int(q)
a = f*enc % q
b = inverse(f,g)*a % g
return long_to_bytes(b)
a = bytes_to_long(open("enc", "rb").read())
print(decrypt(a, f, g, h, q))