import time from cryptography.hazmat.primitives.asymmetric import ec from cryptography.hazmat.primitives import hashes import _helpers import struct from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat, PrivateFormat, NoEncryption from cryptography.hazmat.primitives.asymmetric.utils import decode_dss_signature def sign_prekey(): pre_key = _helpers.create_compactable_key() device_key = _helpers.create_compactable_key() print("DEV PRIV KEY: " + _helpers.parse_key(device_key).private_bytes(Encoding.DER, PrivateFormat.PKCS8, NoEncryption()).hex()) timestamp = time.time() # Set decimal to 0 timestamp = float(int(timestamp)) to_sign = b"NGMPrekeySignature" + _helpers.compact_key(_helpers.parse_key(pre_key)) + struct.pack("