-
Notifications
You must be signed in to change notification settings - Fork 2
/
cryptography.py
29 lines (23 loc) · 952 Bytes
/
cryptography.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import gmpy2
p = 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084171
g = 11717829880366207009516117596335367088558084999998952205599979459063929499736583746670572176471460312928594829675428279466566527115212748467589894601965568
p = 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084171
def calc1(i):
denominv = pow(g, i, p)
denom = gmpy2.invert(denominv, p)
tval = gmpy2.mul(h, denom)
retval = gmpy2.f_mod(tval, p)
return retval
def calc2(i):
return pow(g, (2**20)*i, p)
hasht = {}
for i in range(0,2**20):
hasht[calc1(i)] = i
for i in range(0, 2**20):
c2 = calc2(i)
if c2 in hasht:
print "x0: ", i
print "x1: ", hasht[c2]
break
x = (((357984 * 2**20) + 787046)% p)
print x