MCPcopy Index your code
hub / github.com/petertodd/python-bitcoinlib / CompareBigEndian

Function CompareBigEndian

bitcoin/core/script.py:894–917  ·  view source on GitHub ↗

Loosely matches CompareBigEndian() from eccryptoverify.cpp Compares two arrays of bytes, and returns a negative value if the first is less than the second, 0 if they're equal, and a positive value if the first is greater than the second.

(c1, c2)

Source from the content-addressed store, hash-verified

892 CompareBigEndian(s_val, max_mod_half_order) <= 0
893
894def CompareBigEndian(c1, c2):
895 """
896 Loosely matches CompareBigEndian() from eccryptoverify.cpp
897 Compares two arrays of bytes, and returns a negative value if the first is
898 less than the second, 0 if they&#x27;re equal, and a positive value if the
899 first is greater than the second.
900 """
901 c1 = list(c1)
902 c2 = list(c2)
903
904 # Adjust starting positions until remaining lengths of the two arrays match
905 while len(c1) > len(c2):
906 if c1.pop(0) > 0:
907 return 1
908 while len(c2) > len(c1):
909 if c2.pop(0) > 0:
910 return -1
911
912 while len(c1) > 0:
913 diff = c1.pop(0) - c2.pop(0)
914 if diff != 0:
915 return diff
916
917 return 0
918
919
920def RawSignatureHash(script, txTo, inIdx, hashtype):

Callers 1

IsLowDERSignatureFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected