def op_checksig(stack, signature_for_hash_type_f, expected_hash_type, tmp_script, flags):
    try:
        pair_blob = stack.pop()
        sig_blob = stack.pop()
        verify_strict = not not (flags & VERIFY_STRICTENC)
        # if verify_strict flag is set, we fail the script immediately on bad encoding
        if verify_strict:
            check_public_key_encoding(pair_blob)
        sig_pair, signature_type = parse_signature_blob(sig_blob, flags)
        public_pair = sec_to_public_pair(pair_blob, strict=verify_strict)
    except (der.UnexpectedDER, __HOLE__, EncodingError):
        stack.append(VCH_FALSE)
        return

    if expected_hash_type not in (None, signature_type):
        raise ScriptError("wrong hash type")

    # Drop the signature, since there's no way for a signature to sign itself
    # see: Bitcoin Core/script/interpreter.cpp::EvalScript()
    tmp_script = delete_subscript(tmp_script, bin_script([sig_blob]))

    signature_hash = signature_for_hash_type_f(signature_type, script=tmp_script)

    if ecdsa.verify(ecdsa.generator_secp256k1, public_pair, signature_hash, sig_pair):
        stack.append(VCH_TRUE)
    else:
        stack.append(VCH_FALSE)
dataset/ETHPy150Open richardkiss/pycoin/pycoin/tx/script/check_signature.py/op_checksig