16 lines
446 B
Python
16 lines
446 B
Python
from crypt_random import secure_random
|
|
|
|
|
|
|
|
|
|
class Connection:
|
|
def load_public_constants(self):
|
|
with open("public_constants.txt", "r") as f:
|
|
self.P = int(f.readline(), 16)
|
|
self.G = int(f.readline(), 16)
|
|
|
|
def __init__(self):
|
|
self.load_public_constants()
|
|
|
|
self.private_key = int.from_bytes(secure_random(1024), "big")
|
|
self.public_key = pow(self.G, self.private_key) % self.P |