from web3.auto import w3 from eth_account.messages import encode_defunct from flipbook import config 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 def allowed_file(filename): return "." in filename and \ filename.rsplit(".", 1)[1].lower() in config.ALLOWED_EXTENSIONS