10000 ecdsa.py: fix flakes · tlsfuzzer/python-ecdsa@2a58dda · GitHub
[go: up one dir, main page]

Skip to content

Commit 2a58dda

Browse files
committed
ecdsa.py: fix flakes
1 parent bf13df2 commit 2a58dda

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/ecdsa/ecdsa.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ def __init__(self, generator, point, verify=True):
139139
raise InvalidPointError("Generator point order is bad.")
140140

141141
def __eq__(self, other):
142-
if isinstance(other, Public_key):
142+
if isinstance(other, Public_key):
143143
"""Return True if the points are identical, False otherwise."""
144144
return self.curve == other.curve \
145-
and self.point == other.point
145+
and self.point == other.point
146146
return NotImplemented
147147

148148
def verifies(self, hash, signature):
@@ -182,12 +182,12 @@ def __init__(self, public_key, secret_multiplier):
182182

183183
self.public_key = public_key
184184
self.secret_multiplier = secret_multiplier
185-
185+
186186
def __eq__(self, other):
187-
if isinstance(other, Private_key):
187+
if isinstance(other, Private_key):
188188
"""Return True if the points are identical, False otherwise."""
189189
return self.public_key == other.public_key \
190-
and self.secret_multiplier == other.secret_multiplier
190+
and self.secret_multiplier == other.secret_multiplier
191191
return NotImplemented
192192

193193
def sign(self, hash, random_k):
@@ -220,8 +220,8 @@ def sign(self, hash, random_k):
220220
r = p1.x() % n
221221
if r == 0:
222222
raise RSZeroError("amazingly unlucky random number r")
223-
s = (numbertheory.inverse_mod(k, n) *
224-
(hash + (self.secret_multiplier * r) % n)) % n
223+
s = (numbertheory.inverse_mod(k, n)
224+
* (hash + (self.secret_multiplier * r) % n)) % n
225225
if s == 0:
226226
raise RSZeroError("amazingly unlucky random number s")
227227
return Signature(r, s)
@@ -277,8 +277,8 @@ def point_is_valid(generator, x, y):
277277
if not curve.contains_point(x, y):
278278
return False
279279
if curve.cofactor() != 1 and \
280-
not n * ellipticcurve.PointJacobi(curve, x, y, 1)\
281-
== ellipticcurve.INFINITY:
280+
not n * ellipticcurve.PointJacobi(curve, x, y, 1)\
281+
== ellipticcurve.INFINITY:
282282
return False
283283
return True
284284

@@ -361,7 +361,7 @@ def point_is_valid(generator, x, y):
361361
generator_secp256k1 = ellipticcurve.PointJacobi(
362362
curve_secp256k1, _Gx, _Gy, 1, _r, generator=True)
363363

364-
# Brainpool P-160-r1
364+
# Brainpool P-160-r1
365365
_a = 0x340E7BE2A280EB74E2BE61BADA745D97E8F7C300
366366
_b = 0x1E589A8595423412134FAA2DBDEC95C8D8675E58
367367
_p = 0xE95E4A5F737059DC60DFC7AD95B3D8139515620F

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,5 @@ exclude = src/ecdsa/test*.py
9393
# E502: the backslash is redundant between brackets
9494
# E741: ambiguous variable name
9595
# W391: blank line at end of file
96-
ignore = E111,E114,E226,E231,E266,E302,E305,E501,E502,W391,E741
96+
# W503: line break before binary operator
97+
ignore = E111,E114,E226,E231,E266,E302,E305,E501,E502,W391,E741,W503

0 commit comments

Comments
 (0)
0