This commit is contained in:
Maxime Vorwerk
2024-07-08 16:53:25 +02:00
parent e96f171871
commit 4da8a0067f
2 changed files with 35 additions and 0 deletions

4
minirsa/ciphertext Executable file
View File

@@ -0,0 +1,4 @@
N: 29331922499794985782735976045591164936683059380558950386560160105740343201513369939006307531165922708949619162698623675349030430859547825708994708321803705309459438099340427770580064400911431856656901982789948285309956111848686906152664473350940486507451771223435835260168971210087470894448460745593956840586530527915802541450092946574694809584880896601317519794442862977471129319781313161842056501715040555964011899589002863730868679527184420789010551475067862907739054966183120621407246398518098981106431219207697870293412176440482900183550467375190239898455201170831410460483829448603477361305838743852756938687673
e: 3
ciphertext (c): 2205316413931134031074603746928247799030155221252519872650073010782049179856976080512716237308882294226369300412719995904064931819531456392957957122459640736424089744772221933500860936331459280832211445548332429338572369823704784625368933

31
minirsa/sol.py Executable file
View File

@@ -0,0 +1,31 @@
#!/home/maxime/.pyvenv/bin/python3
from math import sqrt
def iroot(k, n):
u, s = n, n+1
while u < s:
s = u
t = (k-1) * s + n // pow(s, k-1)
u = t // k
return s
with open("ciphertext", 'r') as f:
file = f.read().splitlines()
N = int(file[0][2:].strip())
e = int(file[1][2:].strip())
c = int(file[3][16:].strip())
#sol = 3533
#'''
for i in range(10000):
c_nomod = c+i*N
p = iroot(e, c_nomod)
if p**3 == c_nomod:
print(i)
break
#'''
#p = iroot(e, c+sol*N)
result = p.to_bytes((p.bit_length()+7)//8, byteorder='big')
print(result)