from web3.auto import w3 from eth_account.messages import encode_defunct def verify_signature(message, signature, public_address): msg = encode_defunct(text=message) recovered = w3.eth.account.recover_message(msg, signature=signature) if recovered.lower() == public_address.lower(): return True else: return False