Advertisement
ghost423543

dat_sad_Isitdtu_2021

Dec 26th, 2021
1,354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. from sage.all_cmdline import *
  2. from sage.all import *
  3. from extern_module import *
  4. import os,time
  5. from Crypto.Util import number
  6. start = time.time()
  7. DIR = os.path.dirname(os.path.realpath(__file__))
  8. f = open(f'{DIR}/dump.txt','rb')# collect 65537 pair c-n
  9. m_list,c_list = [],[]
  10. for line in f.read().split(b'\n')[:-1]:
  11.     (n,c) = [int(i) for i in line.split(b':::')]
  12.     m_list.append(n)
  13.     c_list.append(c)
  14. # m_list = [n1,n2,n3]
  15. # c_list = [c1,c2,c3]
  16. f.close()
  17. print("TAG")
  18. # dump = crt(c_list,m_list)
  19. # f = open(f'{DIR}/result.txt','wb')
  20. # f.write(str(dump).encode());f.close()
  21. ## => crt pair same bit_length faster than sequence crt
  22. e = 65537
  23. step = 12
  24. while len(m_list)!=1:
  25.     print("LOOP")
  26.     newC,newN = [],[]
  27.     for i in range(0, len(m_list), step):
  28.         RESULT = Integer(crt(c_list[i:i+step], m_list[i:i+step]))
  29.         # if RESULT==0:continue
  30.         prod = 1
  31.         for _m in m_list[i:i+step]:prod *= _m
  32.         newC.append(RESULT)
  33.         newN.append(Integer(prod))
  34.     c_list = newC
  35.     m_list = newN
  36. m = int(c_list[0]**(Integer(1)/Integer(e)))
  37. print(m.to_bytes((m.bit_length()+7)//8,'big'))
  38. print("Time run:",time.time()-start)
  39. # ISITDTU{DATSAD_1s_Hastad_h4v3_yOu_3vEr_n0t1ced_dat?_BTW_you_should_start_this_challenge_ASAP_otherwise_it_is_too_late!!!!!}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement