def verify(msghash: bytes, signature, public_key): """Verify that data has been signed with Etheruem private key. :param signature: :return: """ key_api = KeyAPI('eth_keys.backends.NativeECCBackend') return key_api.ecdsa_verify(msghash, Signature(signature), PublicKey(public_key))
def validate(transaction, signature, public_key): try: s = Signature(signature_bytes=signature) txID = hashlib.sha256( bytes.fromhex(transaction) if type(transaction) is str else transaction).digest() keys = KeyAPI('eth_keys.backends.NativeECCBackend') publicKey = PublicKey(bytes.fromhex(public_key)) return keys.ecdsa_verify(txID, s, publicKey), txID.hex() except: return False, ""
def validateHASH(txID, signature, public_key): s = Signature(signature_bytes=signature) keys = KeyAPI('eth_keys.backends.NativeECCBackend') publicKey = PublicKey(bytes.fromhex(public_key)) return keys.ecdsa_verify(txID, s, publicKey)
def verify_signature(hash, sig, pub): keys = KeyAPI(NativeECCBackend) sign = keys.Signature(sig) public = keys.PublicKey(pub, base.BaseECCBackend) return keys.ecdsa_verify(hash, sign, public)