Skip to content

Commit

Permalink
Sync eth_keys stub with actual code
Browse files Browse the repository at this point in the history
  • Loading branch information
cburgdorf authored and pipermerriam committed May 24, 2018
1 parent 306564e commit 7f33392
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 41 deletions.
59 changes: 35 additions & 24 deletions stubs/eth_keys/datatypes.pyi
@@ -1,25 +1,37 @@
import collections
from typing import Any, Optional, Text, Tuple
from typing import (
Any,
Optional,
Tuple,
Type,
Union
)

from backends.base import BaseECCBackend

class LazyBackend:
def __init__(
self,
backend: 'Union[BaseECCBackend, Type[BaseECCBackend], str]'=None
) -> None: ...

class BackendProxied:
@property
def backend(self): ...
def backend(self) -> BaseECCBackend: ...
@classmethod
def get_backend(cls): ...
def get_backend(cls) -> BaseECCBackend: ...

class BaseKey(collections.abc.ByteString, collections.Hashable):
def to_hex(self) -> Text: ...
def to_hex(self) -> str: ...
def to_bytes(self) -> bytes: ...
def __hash__(self): ...
def __unicode__(self): ...
def __int__(self): ...
def __len__(self): ...
def __getitem__(self, index): ...
def __hash__(self) -> int: ...
def __int__(self) -> int: ...
def __len__(self) -> int: ...
def __getitem__(self, index: int) -> int: ... # type: ignore
def __eq__(self, other: Any) -> bool: ...
def __index__(self): ...
def __hex__(self) -> Text: ...
def __index__(self) -> int: ...
def __hex__(self) -> str: ...

class PublicKey(BaseKey, BackendProxied):
class PublicKey(BaseKey, LazyBackend):
def __init__(self, public_key_bytes: bytes) -> None: ...
@classmethod
def from_private(cls, private_key: PrivateKey) -> PublicKey: ...
Expand All @@ -33,13 +45,13 @@ class PublicKey(BaseKey, BackendProxied):
def to_address(self) -> bytes: ...
def to_canonical_address(self) -> bytes: ...

class PrivateKey(BaseKey, BackendProxied):
class PrivateKey(BaseKey, LazyBackend):
public_key: PublicKey = ...
def __init__(self, private_key_bytes: bytes) -> None: ...
def sign_msg(self, message: bytes) -> Signature: ...
def sign_msg_hash(self, message_hash: bytes) -> Signature: ...

class Signature(collections.abc.ByteString, BackendProxied):
class Signature(collections.abc.ByteString, LazyBackend):
r: int = ...
s: int = ...
v: int = ...
Expand All @@ -58,18 +70,17 @@ class Signature(collections.abc.ByteString, BackendProxied):
def s(self, value: int) -> None: ...
@property
def vrs(self) -> Tuple[int, int, int]: ...
def to_hex(self) -> Text: ...
def to_hex(self) -> str: ...
def to_bytes(self) -> bytes: ...
def __hash__(self): ...
def __hash__(self) -> int: ...
def __bytes__(self) -> bytes: ...
def __unicode__(self): ...
def __len__(self): ...
def __eq__(self, other): ...
def __getitem__(self, index): ...
def __len__(self) -> int: ...
def __eq__(self, other: Any) -> bool: ...
def __getitem__(self, index: int) -> int: ... # type: ignore
def verify_msg(self, message: bytes, public_key: PublicKey) -> bool: ...
def verify_msg_hash(self, message_hash: bytes, public_key: PublicKey) -> bool: ...
def recover_public_key_from_msg(self, message: bytes) -> PublicKey: ...
def recover_public_key_from_msg_hash(self, message_hash: bytes) -> PublicKey: ...
def __index__(self): ...
def __hex__(self) -> Text: ...
def __int__(self): ...
def __index__(self) -> int: ...
def __hex__(self) -> str: ...
def __int__(self) -> int: ...
37 changes: 20 additions & 17 deletions stubs/eth_keys/main.pyi
@@ -1,21 +1,24 @@
from eth_keys.datatypes import PrivateKey, PublicKey, Signature
from typing import Any, Optional, Union
from typing import (
Any,
Optional,
Type,
Union
)

def backend_property_proxy(name): ...
from .datatypes import (
LazyBackend,
)

class KeyAPI:
backend: Any = ...
def __init__(self, backend: Optional[Any] = ...) -> None: ...
@property
def backend(self): ...
@backend.setter
def backend(self, value): ...
PublicKey: Any = ...
PrivateKey: Any = ...
Signature: Any = ...
def ecdsa_sign(self, message_hash: bytes, private_key: Union[PrivateKey, bytes]) -> Optional[Signature]: ...
def ecdsa_verify(self, message_hash: bytes, signature: Union[Signature, bytes], public_key: Union[PublicKey, bytes]) -> Optional[bool]: ...
def ecdsa_recover(self, message_hash: bytes, signature: Union[Signature, bytes]) -> Optional[PublicKey]: ...
def private_key_to_public_key(self, private_key): ...
import datatypes


class KeyAPI(LazyBackend):
PublicKey: Type[datatypes.PublicKey] = ...
PrivateKey: Type[datatypes.PrivateKey] = ...
Signature: Type[datatypes.Signature] = ...
def ecdsa_sign(self, message_hash: bytes, private_key: Union[datatypes.PrivateKey, bytes]) -> Optional[datatypes.Signature]: ...
def ecdsa_verify(self, message_hash: bytes, signature: Union[datatypes.Signature, bytes], public_key: Union[datatypes.PublicKey, bytes]) -> Optional[bool]: ...
def ecdsa_recover(self, message_hash: bytes, signature: Union[datatypes.Signature, bytes]) -> Optional[datatypes.PublicKey]: ...
def private_key_to_public_key(self, private_key: datatypes.PrivateKey) -> datatypes.PublicKey: ...

lazy_key_api: KeyAPI

0 comments on commit 7f33392

Please sign in to comment.