Esempio n. 1
0
    def dump_and_encrypt_for(self, recipient_pubkey: PublicKey) -> bytes:
        """
        Raises:
            DataError
        """
        try:
            raw = self.dump()
            return recipient_pubkey.encrypt_for_self(raw)

        except CryptoError as exc:
            raise DataError(str(exc)) from exc
Esempio n. 2
0
    def dump_sign_and_encrypt_for(self, author_signkey: SigningKey,
                                  recipient_pubkey: PublicKey) -> bytes:
        """
        Raises:
            DataError
        """
        try:
            signed = author_signkey.sign(self._serialize())
            return recipient_pubkey.encrypt_for_self(signed)

        except CryptoError as exc:
            raise DataError(str(exc)) from exc