Updated script.py to use external API for verifying Standard Ops signatures
This commit is contained in:
parent
042f3da96e
commit
0a3bf90767
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user