From 498d0064cd80c198c63c92adeb93e6d6d87f3f97 Mon Sep 17 00:00:00 2001 From: Vivek Teega Date: Tue, 12 Jul 2022 11:20:24 +0000 Subject: [PATCH] Update verify_signature_standard_ops to check if the floid is same as public key --- pyflo/functions/script.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/pyflo/functions/script.py b/pyflo/functions/script.py index 274676d..744bef9 100644 --- a/pyflo/functions/script.py +++ b/pyflo/functions/script.py @@ -403,25 +403,30 @@ def verify_signature(sig, pub_key, msg): return True if result else False -def verify_signature_standard_ops(sig, pub_key, msg): +def verify_signature_standard_ops(sig, pub_key, msg, flo_id): """ Verify signature for message and given public key :param sig: signature in bytes or HEX encoded string. :param pub_key: public key in bytes or HEX encoded string. - :param msg: message in bytes or HEX encoded string. + :param msg: message in bytes, string or HEX encoded string. + :flo_id: FLO ID in HEX encoded string. :return: boolean. """ - url = 'https://flo-sign-validator.duckdns.org' - post_data = { - 'pubKey': pub_key, - 'message': msg, - 'sign': sig - } - signature_verification = requests.post(url, json = post_data) - signature_verification = json.loads(signature_verification.text) - if signature_verification['message_sign_match']: - return True + derived_floid = pyflo.Address(pub_key) + if flo_id==derived_floid: + url = 'https://flo-sign-validator.duckdns.org' + post_data = { + 'pubKey': pub_key, + 'message': msg, + 'sign': sig + } + signature_verification = requests.post(url, json = post_data) + signature_verification = json.loads(signature_verification.text) + if signature_verification['message_sign_match']: + return True + else: + return False else: return False