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:
@@ -303,7 +303,9 @@ class ECPubkey(object):
|
|||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
if not isinstance(other, ECPubkey):
|
if not isinstance(other, ECPubkey):
|
||||||
raise TypeError('comparison not defined for ECPubkey and {}'.format(type(other)))
|
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:
|
def verify_message_for_address(self, sig65: bytes, message: bytes, algo=lambda x: sha256d(msg_magic(x))) -> bool:
|
||||||
assert_bytes(message)
|
assert_bytes(message)
|
||||||
|
|||||||
Reference in New Issue
Block a user