Browse Source

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
```
master
SomberNight 3 years ago
parent
commit
2d6e34c8c2
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 4
      electrum/ecc.py

4
electrum/ecc.py

@ -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)

Loading…
Cancel
Save