def __init__(self, private_key: X25519PrivateKey, my_secret_x: int):
     self.private_key = private_key
     self.private_key_bytes = private_key.private_bytes(
         Encoding.Raw, PrivateFormat.Raw, NoEncryption())
     self.my_secret_x = my_secret_x
     self.peer_secret_x = None
     self.noise = None
     self.reader = None
     self.writer = None
     self.recv_queue: List[bytes] = []
Exemplo n.º 2
0
def serialize_private_key(private_key: X25519PrivateKey) -> bytes:
    # Takes a X25519PrivateKey object and returns a bytestring representing this key.
    return private_key.private_bytes(
        encoding=serialization.Encoding.PEM,
        format=serialization.PrivateFormat.PKCS8,
        encryption_algorithm=serialization.BestAvailableEncryption(b'pw'))
Exemplo n.º 3
0
def serialize_private_key_raw(private_key: X25519PrivateKey) -> bytes:
    return private_key.private_bytes(
        encoding=serialization.Encoding.Raw,
        format=serialization.PrivateFormat.Raw,
        encryption_algorithm=serialization.NoEncryption())