import dataclasses

import msgpack

from source.packets import base


@dataclasses.dataclass
class KeyPacket(base.BasePacket):
    """
    Represent a packet containing a secret symmetric key
    """

    secret_key: bytes = dataclasses.field(repr=False)

    def pack(self) -> bytes:
        return msgpack.packb((
            self.secret_key
        ))

    @classmethod
    def unpack(cls, data: bytes):
        return cls(*msgpack.unpackb(data))
