from . import ids_pb2, _helpers import struct,time from cryptography.hazmat.primitives.asymmetric import ec from cryptography.hazmat.primitives import hashes import logging logger = logging.getLogger("ids") class NGMIdentity: def __init__(self, device_key: str | None, pre_key: str | None): if device_key is None: device_key = _helpers.create_compactable_key() if pre_key is None: pre_key = _helpers.create_compactable_key() self.device_key = device_key self.pre_key = pre_key def sign_prekey(self): timestamp = time.time() to_sign = b"NGMPrekeySignature" + _helpers.compact_key(_helpers.parse_key(self.pre_key)) + struct.pack("