import hmac
import hashlib


def is_slack_request_valid(
        ts: str, 
        body: str, 
        signature: str, 
        signing_secret:str ) -> bool:
    """verifies a request with signed secret approach
    
    Args:
        ts = timestamp of request from X-Slack-Request-Timestamp header
        body = string of request body
        signature = signature of request from X-Slack-Signature header
        signing_secret = signing secret of this app
    
    Returns:
        true if signatures match
        false otherwise
    """
    version = "v0"        
    base_string = ":".join([version, ts, body])    
    h = hmac.new(
        signing_secret.encode("utf-8"), 
        base_string.encode("utf-8"), 
        hashlib.sha256 
    )
    my_signature = version + "=" + h.hexdigest()
    return my_signature == signature