Skip to content

Commit

Permalink
fix LGTM alerts
Browse files Browse the repository at this point in the history
remove unused imports, bad assert methods, unused variables etc.
  • Loading branch information
tomato42 committed Dec 11, 2020
1 parent 24afc18 commit a690d1f
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 21 deletions.
4 changes: 4 additions & 0 deletions src/ecdsa/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# while we don't use six in this file, we did bundle it for a long time, so
# keep as part of module in a virtual way (through __all__)
import six
from .keys import (
SigningKey,
VerifyingKey,
Expand Down Expand Up @@ -80,5 +83,6 @@
SECP112r2,
SECP128r1,
SECP160r1,
six.b(""),
]
del _hush_pyflakes
2 changes: 1 addition & 1 deletion src/ecdsa/ellipticcurve.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ def mul_add(self, self_mul, other, other_mul):
calculates self*self_mul + other*other_mul
"""
if other is INFINITY or other_mul == 0:
if other == INFINITY or other_mul == 0:
return self * self_mul
if self_mul == 0:
return other * other_mul
Expand Down
1 change: 0 additions & 1 deletion src/ecdsa/numbertheory.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ def factorization(n):
return []

result = []
d = 2

# Test the small primes:

Expand Down
2 changes: 1 addition & 1 deletion src/ecdsa/test_der.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import unittest
from six import b
import hypothesis.strategies as st
from hypothesis import given, example
from hypothesis import given
import pytest
from ._compat import str_idx_as_int
from .curves import NIST256p, NIST224p
Expand Down
2 changes: 1 addition & 1 deletion src/ecdsa/test_ecdh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import shutil
import subprocess
import pytest
from binascii import hexlify, unhexlify
from binascii import unhexlify

try:
import unittest2 as unittest
Expand Down
3 changes: 1 addition & 2 deletions src/ecdsa/test_ellipticcurve.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pytest
from six import print_

try:
import unittest2 as unittest
Expand Down Expand Up @@ -96,7 +95,7 @@ def test_conflation_curves(self):
self.assertEqual(len(set((c_23, eq1, eq2, eq3))), 1)
self.assertEqual(len(set((c_23, ne1, ne2, ne3))), 4)
self.assertDictEqual({c_23: None}, {eq1: None})
self.assertTrue(eq2 in {eq3: None})
self.assertIn(eq2, {eq3: None})


class TestPoint(unittest.TestCase):
Expand Down
4 changes: 1 addition & 3 deletions src/ecdsa/test_jacobi.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import hypothesis.strategies as st
from hypothesis import given, assume, settings, example

from .ellipticcurve import CurveFp, Point, PointJacobi, INFINITY
from .ellipticcurve import CurveFp, PointJacobi, INFINITY
from .ecdsa import (
generator_256,
curve_256,
Expand Down Expand Up @@ -473,8 +473,6 @@ def test_mul_add_without_order(self):
def test_mul_add_with_doubled_negation_of_itself(self):
j_g = PointJacobi.from_affine(generator_256 * 17)

order = generator_256.order()

dbl_neg = 2 * (-j_g)

self.assertEqual(j_g.mul_add(4, dbl_neg, 2), INFINITY)
Expand Down
2 changes: 0 additions & 2 deletions src/ecdsa/test_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
buffer = memoryview

import array
import six
import sys
import pytest
import hashlib

Expand Down
3 changes: 1 addition & 2 deletions src/ecdsa/test_malformed_sigs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
from functools import partial
import pytest
import sys
from six import binary_type
import hypothesis.strategies as st
from hypothesis import note, assume, given, settings, example

from .keys import SigningKey
from .keys import BadSignatureError
from .util import sigencode_der, sigencode_string
from .util import sigdecode_der, sigdecode_string
from .curves import curves, NIST256p
from .curves import curves
from .der import (
encode_integer,
encode_bitstring,
Expand Down
2 changes: 0 additions & 2 deletions src/ecdsa/test_numbertheory.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import operator
from six import print_
from functools import reduce
import operator

try:
import unittest2 as unittest
Expand Down
6 changes: 0 additions & 6 deletions src/ecdsa/test_pyecdsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
except ImportError:
import unittest
import os
import time
import shutil
import subprocess
import pytest
Expand Down Expand Up @@ -140,16 +139,12 @@ def test_lengths(self):
BRAINPOOLP384r1,
BRAINPOOLP512r1,
):
start = time.time()
priv = SigningKey.generate(curve=curve)
pub1 = priv.get_verifying_key()
keygen_time = time.time() - start
pub2 = VerifyingKey.from_string(pub1.to_string(), curve)
self.assertEqual(pub1.to_string(), pub2.to_string())
self.assertEqual(len(pub1.to_string()), curve.verifying_key_length)
start = time.time()
sig = priv.sign(b("data"))
sign_time = time.time() - start
self.assertEqual(len(sig), curve.signature_length)

def test_serialize(self):
Expand Down Expand Up @@ -1282,7 +1277,6 @@ class TooSmallCurve(unittest.TestCase):
)
def test_sign_too_small_curve_dont_allow_truncate_raises(self):
sk = SigningKey.generate(curve=NIST192p)
vk = sk.get_verifying_key()
data = b("data")
with self.assertRaises(BadDigestError):
sk.sign(
Expand Down

0 comments on commit a690d1f

Please sign in to comment.