Implemented ratchet generation, rotation and persistence

This commit is contained in:
Mark Qvist 2024-09-04 12:02:55 +02:00
parent 2bf75f60bc
commit 54eaff203f
2 changed files with 73 additions and 2 deletions

View file

@ -221,6 +221,16 @@ class Identity:
"""
return Identity.truncated_hash(os.urandom(Identity.TRUNCATED_HASHLENGTH//8))
@staticmethod
def generate_ratchet():
ratchet_prv = X25519PrivateKey.generate()
ratchet_pub = ratchet_prv.public_key()
return ratchet_prv.private_bytes()
@staticmethod
def ratchet_public_bytes(ratchet):
return X25519PrivateKey.from_private_bytes(ratchet).public_key().public_bytes()
@staticmethod
def validate_announce(packet, only_validate_signature=False):
try: