def _input_valid()

in resdb_driver/transaction.py [0:0]


    def _input_valid(input_, operation, message, output_condition_uri=None):
        """! Validates a single Input against a single Output.
        Note:
            In case of a `CREATE` Transaction, this method
            does not validate against `output_condition_uri`.

        @param input_ (:class:`~resdb.transaction.Input`) The Input to be signed.
        @param operation (str): The type of Transaction.
        @param message (str): The fulfillment message.
        @param output_condition_uri (str, optional): An Output to check the
            Input against.
        @return If the Input is valid.
        """
        ccffill = input_.fulfillment
        try:
            parsed_ffill = Fulfillment.from_uri(ccffill.serialize_uri())
        except (TypeError, ValueError, ParsingError, ASN1DecodeError, ASN1EncodeError):
            return False

        if operation == Transaction.CREATE:
            # NOTE: In the case of a `CREATE` transaction, the
            #       output is always valid.
            output_valid = True
        else:
            output_valid = output_condition_uri == ccffill.condition_uri

        message = sha3_256(message.encode())
        if input_.fulfills:
            message.update(
                "{}{}".format(input_.fulfills.txid,
                              input_.fulfills.output).encode()
            )

        # NOTE: We pass a timestamp to `.validate`, as in case of a timeout
        #       condition we'll have to validate against it

        # cryptoconditions makes no assumptions of the encoding of the
        # message to sign or verify. It only accepts bytestrings
        ffill_valid = parsed_ffill.validate(message=message.digest())
        return output_valid and ffill_valid