Skip to content

Commit

Permalink
Adding py_ecc module and mypy changes
Browse files Browse the repository at this point in the history
* Adding common types module
* Adding mypy correction from tox
  • Loading branch information
6ug committed Oct 18, 2018
1 parent e4de2be commit 9549bd6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 1 addition & 3 deletions py_ecc/bn128/bn128_field_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import sys
from typing import NewType, Tuple
from py_ecc.types import Point2D, Point3D

sys.setrecursionlimit(10000)

Expand All @@ -12,9 +13,6 @@
else:
int_types = (int,)

Point2D = Tuple[int, int]
Point3D = Tuple[int, int, int]

# The prime modulus of the field
field_modulus = 21888242871839275222246405745257275088696311157297823662689037894645226208583
# See, it's prime!
Expand Down
4 changes: 1 addition & 3 deletions py_ecc/secp256k1/secp256k1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import hmac
import sys
from typing import NewType, Tuple, Union
from py_ecc.types import Point2D, Point3D

if sys.version_info.major == 2:
safe_ord = ord
Expand All @@ -12,9 +13,6 @@ def safe_ord(value):
else:
return ord(value)

Point2D = Tuple[int, int]
Point3D = Tuple[int, int, int]

# Elliptic curve parameters (secp256k1)
P = 2**256 - 2**32 - 977
N = 115792089237316195423570985008687907852837564279074904382605163141518161494337
Expand Down
5 changes: 5 additions & 0 deletions py_ecc/types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Represents common DRY module to avoid repetition
from typing import Tuple

Point2D = Tuple[int, int]
Point3D = Tuple[int, int, int]
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ basepython=python
extras=lint
commands=
flake8 {toxinidir}/py_ecc
mypy --follow-imports=silent --warn-unused-ignores --ignore-missing-imports --no-strict-optional --check-untyped-defs --disallow-incomplete-defs --disallow-untyped-defs --disallow-any-generics -p p2p -p py_ecc
mypy --follow-imports=silent --warn-unused-ignores --ignore-missing-imports --no-strict-optional --check-untyped-defs --disallow-incomplete-defs --disallow-untyped-defs --disallow-any-generics -p py_ecc

0 comments on commit 9549bd6

Please sign in to comment.