|
12 | 12 |
|
13 | 13 | mypy aliases, documenting also coding input conventions.
|
14 | 14 | """
|
| 15 | +from __future__ import annotations |
15 | 16 |
|
16 | 17 | from io import BytesIO
|
17 | 18 | from typing import Any, Callable, Tuple, Union
|
18 | 19 |
|
19 |
| -from typing_extensions import TypeAlias |
20 |
| - |
21 | 20 | # Octets are a sequence of eight-bit bytes or a hex-string (not text string)
|
22 | 21 | #
|
23 | 22 | # hex-strings are strings that can be converted to bytes using bytes.fromhex,
|
|
35 | 34 | # dsa.Sig (DER serialization of ECDSA signature),
|
36 | 35 | # ssa.Sig (BIP340 serialization of Schnorr signature)
|
37 | 36 | # etc.
|
38 |
| -Octets: TypeAlias = Union[bytes, str] |
| 37 | +Octets = Union[bytes, str] |
39 | 38 |
|
40 | 39 | # bytes or text string (not hex-string)
|
41 | 40 | #
|
|
61 | 60 | #
|
62 | 61 | # In those cases often there is no need to encode() to bytes
|
63 | 62 | # as b58decode/b32decode/etc. will take care of that
|
64 |
| -String: TypeAlias = Union[bytes, str] |
| 63 | +String = Union[bytes, str] |
65 | 64 |
|
66 | 65 | # binary data, usually to be cosumed as byte stream,
|
67 | 66 | # but possibily provided as Octets too
|
68 |
| -BinaryData: TypeAlias = Union[BytesIO, Octets] |
| 67 | +BinaryData = Union[BytesIO, Octets] |
69 | 68 |
|
70 | 69 | # hex-string or bytes representation of an int
|
71 | 70 | # Integer = Union[Octets, int]
|
72 |
| -Integer: TypeAlias = Union[bytes, str, int] |
| 71 | +Integer = Union[bytes, str, int] |
73 | 72 |
|
74 | 73 | # Hash digest constructor: it may be any name suitable to hashlib.new()
|
75 |
| -HashF: TypeAlias = Callable[[], Any] |
| 74 | +HashF = Callable[[], Any] |
76 | 75 | # HashF = Callable[[Any], Any]
|
77 | 76 |
|
78 | 77 | # Elliptic curve point in affine coordinates.
|
79 | 78 | # Warning: to make Point a NamedTuple would slow down the code
|
80 |
| -Point: TypeAlias = Tuple[int, int] |
| 79 | +Point = Tuple[int, int] |
81 | 80 |
|
82 | 81 | # Note that the infinity point in affine coordinates is INF = (int, 0)
|
83 | 82 | # (no affine point has y=0 coordinate in a group of prime order).
|
|
88 | 87 | INF = 5, 0
|
89 | 88 |
|
90 | 89 | # Elliptic curve point in Jacobian coordinates.
|
91 |
| -JacPoint: TypeAlias = Tuple[int, int, int] |
| 90 | +JacPoint = Tuple[int, int, int] |
92 | 91 |
|
93 | 92 | # Infinity point in Jacobian coordinates is INF = (int, int, 0).
|
94 | 93 | # It can be checked with 'INF[2] == 0'
|
|
0 commit comments