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)
| 892 | CompareBigEndian(s_val, max_mod_half_order) <= 0 |
| 893 | |
| 894 | def 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'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 | |
| 920 | def RawSignatureHash(script, txTo, inIdx, hashtype): |