1
0

ecc: make ECPubkey.__lt__ relation strongly-connected/total

Previously we had:
```
>>> import electrum
>>> from electrum.ecc import POINT_AT_INFINITY
>>> G = electrum.ecc.GENERATOR
>>> G <= (-1 * G)
False
>>> (-1 * G) <= G
False
```
This commit is contained in:
SomberNight
2023-02-13 08:54:39 +00:00
parent df2bd61de6
commit 2d6e34c8c2

View File

@@ -303,7 +303,9 @@ class ECPubkey(object):
def __lt__(self, other):
if not isinstance(other, ECPubkey):
raise TypeError('comparison not defined for ECPubkey and {}'.format(type(other)))
return (self.x() or 0) < (other.x() or 0)
p1 = ((self.x() or 0), (self.y() or 0))
p2 = ((other.x() or 0), (other.y() or 0))
return p1 < p2
def verify_message_for_address(self, sig65: bytes, message: bytes, algo=lambda x: sha256d(msg_magic(x))) -> bool:
assert_bytes(message)