ALL the CTFS of Crypto2025 finally
This commit is contained in:
30
crypto-asimmetric/inferious_prime/test.py
Normal file
30
crypto-asimmetric/inferious_prime/test.py
Normal file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from Cryptodome.PublicKey import RSA
|
||||
|
||||
|
||||
#kth root of the number n
|
||||
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
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
e = 3
|
||||
# d = rsa_keypair.d
|
||||
n = 388435672474892257936058543724812684332943095105091384265939
|
||||
m = b'A'*8
|
||||
m_int = int.from_bytes(m,byteorder='big')
|
||||
|
||||
c = pow(m_int,e,n)
|
||||
|
||||
decrypted_int = iroot(e, c)
|
||||
print(decrypted_int)
|
||||
print(decrypted_int.to_bytes(decrypted_int.bit_length() // 8 +1, byteorder='big').decode())
|
||||
|
||||
dec = pow(c, 1/3)
|
||||
print(dec)
|
||||
Reference in New Issue
Block a user