Files
appliedcrypto/unit09_future/src/a_05.py
billbuchanan 44789e8d3a Update
2021-01-18 20:47:18 +00:00

32 lines
438 B
Python

import sys
import random
n=101
g= 3
x = random.randint(5,10)
v = random.randint(100,150)
c = random.randint(5,10)
y= g**x % n
t = g**v % n
r = v - c * x
Result = ( (g**r) * (y**c) ) % n
print 'x=',x
print 'c=',c
print 'v=',v
print 'P=',n
print 'G=',g
print '======'
print 't=',t
print 'r=',Result
if (t==Result):
print 'Alice has proven she knows x'
else:
print 'Alice has not proven she knows x'