Skip to content

Commit

Permalink
Merge 1dba4f8 into 4c92d31
Browse files Browse the repository at this point in the history
  • Loading branch information
tomato42 committed Oct 26, 2019
2 parents 4c92d31 + 1dba4f8 commit 930e92a
Show file tree
Hide file tree
Showing 9 changed files with 322 additions and 93 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ coverage-html
.tox
nosetests.xml
t/
.hypothesis/

# Translations
*.mo
Expand Down
17 changes: 7 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ before_install:
TRAVIS_COMMIT_RANGE=$PR_FIRST^..$TRAVIS_COMMIT
fi
# sanity check current commit
- git rev-parse HEAD
- BRANCH=$(git rev-parse HEAD)
- echo "TRAVIS_COMMIT_RANGE=$TRAVIS_COMMIT_RANGE"
- git fetch origin master:refs/remotes/origin/master

Expand All @@ -78,31 +78,28 @@ install:
script:
- if [[ $TOX_ENV ]]; then tox -e $TOX_ENV; fi
- tox -e speed
- cp diff-instrumental.py diff-instrumental-2.py
- |
if [[ $INSTRUMENTAL && $TRAVIS_PULL_REQUEST != "false" ]]; then
git checkout $PR_FIRST^
# exclude the super slow test_malformed_sigs.py, until #127 is merged
files="$(ls src/ecdsa/test*.py | grep -v test_malformed_sigs.py)"
instrumental -t ecdsa -i 'test.*|.*_version' `which pytest` $files
instrumental -f .instrumental.cov -s
instrumental -f .instrumental.cov -s | python diff-instrumental-2.py --save .diff-instrumental
git checkout $TRAVIS_COMMIT
instrumental -t ecdsa -i 'test.*|.*_version' `which pytest` $files
instrumental -f .instrumental.cov -s | python diff-instrumental.py --save .diff-instrumental
git checkout $BRANCH
instrumental -t ecdsa -i 'test.*|.*_version' `which pytest` src/ecdsa
instrumental -f .instrumental.cov -sr
fi
- |
if [[ $INSTRUMENTAL && $TRAVIS_PULL_REQUEST == "false" ]]; then
# exclude the super slow test_malformed_sigs.py, until #127 is merged
files="$(ls src/ecdsa/test*.py | grep -v test_malformed_sigs.py)"
instrumental -t ecdsa -i 'test.*|.*_version' `which pytest` $files
instrumental -t ecdsa -i 'test.*|.*_version' `which pytest` src/ecdsa
instrumental -f .instrumental.cov -s
# just log the values when merging
instrumental -f .instrumental.cov -s | python diff-instrumental-2.py
instrumental -f .instrumental.cov -s | python diff-instrumental.py
fi
- |
if [[ $INSTRUMENTAL && $TRAVIS_PULL_REQUEST != "false" ]]; then
instrumental -f .instrumental.cov -s | python diff-instrumental-2.py --read .diff-instrumental --fail-under 70 --max-difference -0.1
instrumental -f .instrumental.cov -s | python diff-instrumental.py --read .diff-instrumental --fail-under 70 --max-difference -0.1
fi
after_success:
- if [[ -z $INSTRUMENTAL ]]; then coveralls; fi
Expand Down
1 change: 1 addition & 0 deletions build-requirements-2.6.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ tox
coveralls<1.3.0
idna<2.8
unittest2
hypothesis<3
2 changes: 2 additions & 0 deletions build-requirements-3.3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ pluggy<0.6
tox<3
wheel<0.30
virtualenv==15.2.0
enum34
hypothesis<3.44
2 changes: 2 additions & 0 deletions build-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
tox
python-coveralls
hypothesis
pytest>=4.6.0
19 changes: 17 additions & 2 deletions src/ecdsa/curves.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
# will need to mark it as deprecated later
__all__ = ["UnknownCurveError", "orderlen", "Curve", "NIST192p",
"NIST224p", "NIST256p", "NIST384p", "NIST521p", "curves",
"find_curve"]
"find_curve", "SECP256k1"]


class UnknownCurveError(Exception):
pass


# the NIST curves
class Curve:
def __init__(self, name, curve, generator, oid, openssl_name=None):
self.name = name
Expand All @@ -29,25 +28,41 @@ def __init__(self, name, curve, generator, oid, openssl_name=None):
self.oid = oid
self.encoded_oid = der.encode_oid(*oid)

def __repr__(self):
return self.name


# the NIST curves
NIST192p = Curve("NIST192p", ecdsa.curve_192,
ecdsa.generator_192,
(1, 2, 840, 10045, 3, 1, 1), "prime192v1")


NIST224p = Curve("NIST224p", ecdsa.curve_224,
ecdsa.generator_224,
(1, 3, 132, 0, 33), "secp224r1")


NIST256p = Curve("NIST256p", ecdsa.curve_256,
ecdsa.generator_256,
(1, 2, 840, 10045, 3, 1, 7), "prime256v1")


NIST384p = Curve("NIST384p", ecdsa.curve_384,
ecdsa.generator_384,
(1, 3, 132, 0, 34), "secp384r1")


NIST521p = Curve("NIST521p", ecdsa.curve_521,
ecdsa.generator_521,
(1, 3, 132, 0, 35), "secp521r1")


SECP256k1 = Curve("SECP256k1", ecdsa.curve_secp256k1,
ecdsa.generator_secp256k1,
(1, 3, 132, 0, 10), "secp256k1")


curves = [NIST192p, NIST224p, NIST256p, NIST384p, NIST521p, SECP256k1]


Expand Down
5 changes: 5 additions & 0 deletions src/ecdsa/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ def __init__(self, _error__please_use_generate=None):
self.default_hashfunc = None
self.pubkey = None

def __repr__(self):
pub_key = self.to_string("compressed")
return "VerifyingKey.from_string({0!r}, {1!r}, {2})".format(
pub_key, self.curve, self.default_hashfunc().name)

@classmethod
def from_public_point(cls, point, curve=NIST192p, hashfunc=sha1):
"""
Expand Down
Loading

0 comments on commit 930e92a

Please sign in to comment.