cleanup and types correction
This commit is contained in:
parent
428d692283
commit
f4affc480a
BIN
.utils.py.swp
BIN
.utils.py.swp
Binary file not shown.
10
alice.py
10
alice.py
@ -1,10 +0,0 @@
|
||||
from utils import generate_secret
|
||||
from utils import prime, FILE
|
||||
from Crypto.Math.Numbers import Integer, from_bytes
|
||||
|
||||
g = Integer(2)
|
||||
a = generate_secret()
|
||||
A_secret = pow(g, Integer.from_bytes(a), prime)
|
||||
|
||||
with open(FILE, 'wb') as f:
|
||||
f.write(A_secret.to_bytes())
|
16
bob.py
16
bob.py
@ -1,16 +0,0 @@
|
||||
from utils import generate_secret, coin_toss
|
||||
from utils import prime, FILE
|
||||
from Crypto.Math.Numbers import Integer
|
||||
|
||||
g = Integer(2)
|
||||
b = generate_secret()
|
||||
|
||||
B_secret = pow(g, Integer.from_bytes(b), prime)
|
||||
|
||||
if coin_toss():
|
||||
with open(FILE, 'r') as f:
|
||||
A_secret = f.read()
|
||||
B_secret = A_secret * B_secret
|
||||
print('siup')
|
||||
|
||||
print(B_secret)
|
21
main.py
21
main.py
@ -0,0 +1,21 @@
|
||||
from utils import generate_secret, coin_toss
|
||||
from utils import prime, FILE
|
||||
from Crypto.Math.Numbers import Integer
|
||||
|
||||
def alice_1():
|
||||
g = Integer(2)
|
||||
a = generate_secret()
|
||||
A_secret = pow(g, Integer(int.from_bytes(a)), prime)
|
||||
return A_secret
|
||||
|
||||
def bob_1(A_secret):
|
||||
g = Integer(2)
|
||||
b = generate_secret()
|
||||
B_secret = pow(g, Integer.from_bytes(b), prime)
|
||||
if coin_toss():
|
||||
B_secret = A_secret * B_secret
|
||||
return B_secret
|
||||
|
||||
a = alice_1()
|
||||
b = bob_1(a)
|
||||
print(b)
|
Loading…
Reference in New Issue
Block a user