From 0a3bf90767fe906224c5a41cf8c57a71e0148b61 Mon Sep 17 00:00:00 2001 From: Vivek Teega Date: Sun, 10 Jul 2022 06:57:01 +0000 Subject: [PATCH] Updated script.py to use external API for verifying Standard Ops signatures --- pyflo/functions/script.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/pyflo/functions/script.py b/pyflo/functions/script.py index ca737dc..92a98c2 100644 --- a/pyflo/functions/script.py +++ b/pyflo/functions/script.py @@ -22,6 +22,7 @@ from pyflo.functions.tools import bytes_from_hex, int_to_bytes, get_stream from pyflo.functions.hash import hash160, sha256 from pyflo.functions.address import hash_to_address from pyflo.functions.key import is_wif_valid, wif_to_private_key +import requests, json def public_key_to_pubkey_script(key, hex=True): @@ -165,9 +166,6 @@ def script_to_address(script, testnet=False): return None - - - def decode_script(script, asm=False): """ Decode script to ASM format or to human readable OPCODES string. @@ -404,6 +402,29 @@ def verify_signature(sig, pub_key, msg): result = secp256k1_ecdsa_verify(ECDSA_CONTEXT_VERIFY, raw_sig, msg, raw_pubkey) return True if result else False + +def verify_signature_standard_ops(floID, pubKey, message, sign): + """ + 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. + :return: boolean. + """ + url = 'https://flo-sign-validator.duckdns.org' + myobj = { + 'floID': floID, + 'pubKey': pubKey, + 'message': message, + 'sign': sign + } + x = requests.post(url, json = myobj) + x = json.loads(x.text) + # Three possible cases over there.. 2 failures and 1 success + return x + + def to_base(n, base): if base == 10: return n