ECC.pyi 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. from typing import Union, Callable, Optional, NamedTuple, List, Tuple, Dict, NamedTuple, Any
  2. from Cryptodome.Math.Numbers import Integer
  3. RNG = Callable[[int], bytes]
  4. class UnsupportedEccFeature(ValueError): ...
  5. class EccPoint(object):
  6. def __init__(self, x: Union[int, Integer], y: Union[int, Integer], curve: Optional[str] = ...) -> None: ...
  7. def set(self, point: EccPoint) -> EccPoint: ...
  8. def __eq__(self, point: object) -> bool: ...
  9. def __neg__(self) -> EccPoint: ...
  10. def copy(self) -> EccPoint: ...
  11. def is_point_at_infinity(self) -> bool: ...
  12. def point_at_infinity(self) -> EccPoint: ...
  13. @property
  14. def x(self) -> int: ...
  15. @property
  16. def y(self) -> int: ...
  17. @property
  18. def xy(self) -> Tuple[int, int]: ...
  19. def size_in_bytes(self) -> int: ...
  20. def size_in_bits(self) -> int: ...
  21. def double(self) -> EccPoint: ...
  22. def __iadd__(self, point: EccPoint) -> EccPoint: ...
  23. def __add__(self, point: EccPoint) -> EccPoint: ...
  24. def __imul__(self, scalar: int) -> EccPoint: ...
  25. def __mul__(self, scalar: int) -> EccPoint: ...
  26. class EccKey(object):
  27. curve: str
  28. def __init__(self, *, curve: str = ..., d: int = ..., point: EccPoint = ...) -> None: ...
  29. def __eq__(self, other: object) -> bool: ...
  30. def __repr__(self) -> str: ...
  31. def has_private(self) -> bool: ...
  32. @property
  33. def d(self) -> int: ...
  34. @property
  35. def pointQ(self) -> EccPoint: ...
  36. def public_key(self) -> EccKey: ...
  37. def export_key(self, **kwargs: Union[str, bytes, bool]) -> str: ...
  38. _Curve = NamedTuple("_Curve", [('p', Integer),
  39. ('order', Integer),
  40. ('b', Integer),
  41. ('Gx', Integer),
  42. ('Gy', Integer),
  43. ('G', EccPoint),
  44. ('modulus_bits', int),
  45. ('oid', str),
  46. ('context', Any),
  47. ('desc', str),
  48. ('openssh', str),
  49. ])
  50. _curves : Dict[str, _Curve]
  51. def generate(**kwargs: Union[str, RNG]) -> EccKey: ...
  52. def construct(**kwargs: Union[str, int]) -> EccKey: ...
  53. def import_key(encoded: Union[bytes, str], passphrase: Optional[str]=None) -> EccKey: ...