def check_signature(script, signature_hash, public_key_blob, sig_blob, hash_type):
    """Ensure the given transaction has the correct signature. Invoked by the VM.
    Adapted from official Bitcoin-QT client.

    script: the script that is claimed to unlock the coins used in this transaction
    signature_hash: the signature hash of the transaction being verified
    public_key_blob: the blob representing the SEC-encoded public pair
    sig_blob: the blob representing the DER-encoded signature
    hash_type: expected signature_type (or 0 for wild card)
    """
    signature_type = ord(sig_blob[-1:])
    if signature_type != 1:
        raise ScriptError("unknown signature type %d" % signature_type)
    sig_pair = der.sigdecode_der(sig_blob[:-1])
    if hash_type == 0:
        hash_type = signature_type
    elif hash_type != signature_type:
        raise ScriptError("wrong hash type")
    public_pair = sec_to_public_pair(public_key_blob)
    v = ecdsa.verify(ecdsa.generator_secp256k1, public_pair, signature_hash, sig_pair)
    return make_bool(v)
dataset/ETHPy150Open maraoz/proofofexistence/pycoin/tx/script/vm.py/check_signature/original