-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodulus_inutilis.py
21 lines (15 loc) · 1.16 KB
/
modulus_inutilis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from Crypto.Util.number import long_to_bytes
from gmpy2 import iroot
"""
We get that ct = (pt ^ e) mod n. Because 'e' = 3 is a small value, we can simply
calculate pt = (ct ^ 1/3) mod n.
"""
def solve():
n = 17258212916191948536348548470938004244269544560039009244721959293554822498047075403658429865201816363311805874117705688359853941515579440852166618074161313773416434156467811969628473425365608002907061241714688204565170146117869742910273064909154666642642308154422770994836108669814632309362483307560217924183202838588431342622551598499747369771295105890359290073146330677383341121242366368309126850094371525078749496850520075015636716490087482193603562501577348571256210991732071282478547626856068209192987351212490642903450263288650415552403935705444809043563866466823492258216747445926536608548665086042098252335883
e = 3
ciphertext = 243251053617903760309941844835411292373350655973075480264001352919865180151222189820473358411037759381328642957324889519192337152355302808400638052620580409813222660643570085177957
plaintext = iroot(ciphertext, e)[0] % n
flag = long_to_bytes(plaintext).decode()
print(flag)
if __name__ == '__main__':
solve()