def dump_and_encrypt(self, key: SecretKey) -> bytes: """ Raises: DataError """ try: raw = self.dump() return key.encrypt(raw) except CryptoError as exc: raise DataError(str(exc)) from exc
def dump_sign_and_encrypt(self, author_signkey: SigningKey, key: SecretKey) -> bytes: """ Raises: DataError """ try: signed = author_signkey.sign(self._serialize()) return key.encrypt(signed) except CryptoError as exc: raise DataError(str(exc)) from exc