TheTechZone / signal-protocol.py

Experimental Python binding for signalapp/libsignal
GNU Affero General Public License v3.0
3 stars 0 forks source link

expose constructor for `KyberPreKeyRecord` #10

Closed TheTechZone closed 4 weeks ago

TheTechZone commented 1 month ago

libsignal offers pretty nice primitives for handling generating keys along with associated data (such as signatures).

However, KyberPreKeyRecord unlike other state types does not expose a constructor, only a static generate() function. The current workaround is to create a record by deserializing a SignedPreKeyRecordStructure protobuf.

def make_kyber_record(key_id: int, ts: int, kp: KemKeyPair, signature: bytes) -> KyberPreKeyRecord:
    record = SignedPreKeyRecordStructure()
    record.id = key_id
    record.public_key = kp.get_public().serialize()
    record.private_key = kp.get_private().serialize()
    record.signature = signature
    record.timestamp = ts
    return KyberPreKeyRecord.deserialize(record.SerializeToString())

This works but is quite clunky and error prone. Alternatively we could just store the serialized bytestring but that would limit further possibilities.

TheTechZone commented 1 month ago

KyberPreKeyRecord

TheTechZone commented 4 weeks ago

addressed by a9431de