Some type hint and docstring fixes

pull/271/head
Bogdan Opanchuk 2021-06-13 11:03:53 -07:00
parent 104d1a4c20
commit 70fb1157b5
3 changed files with 6 additions and 6 deletions

View File

@ -56,7 +56,7 @@ A delegating key pair and a signing key pair.
Encrypt with a public key
--------------------------
Now let's encrypt data with Alice's public key.
Invocation of :py:func:`encrypt` returns both a ``capsule`` and a ``ciphertext``.
Invocation of :py:func:`umbral.encrypt` returns both a ``capsule`` and a ``ciphertext``.
Note that anyone with Alice's public key can perform this operation.

View File

@ -22,10 +22,10 @@ class Deserializable(HasSerializedSize):
A mixin for composable deserialization.
"""
_T = TypeVar('_T', bound='Deserializable')
Self = TypeVar('Self', bound='Deserializable')
@classmethod
def from_bytes(cls: Type[_T], data: bytes) -> _T:
def from_bytes(cls: Type[Self], data: bytes) -> Self:
"""
Restores the object from serialized bytes.
"""
@ -64,7 +64,7 @@ class Deserializable(HasSerializedSize):
@classmethod
@abstractmethod
def _from_exact_bytes(cls: Type[_T], data: bytes) -> _T:
def _from_exact_bytes(cls: Type[Self], data: bytes) -> Self:
"""
Deserializes the object from a bytestring of exactly the expected length
(defined by ``serialized_size()``).

View File

@ -22,7 +22,7 @@ class Signer:
def __init__(self, secret_key: SecretKey):
self.__secret_key = secret_key
def sign_digest(self, digest: 'Hash') -> 'Signature':
def sign_digest(self, digest: Hash) -> 'Signature':
secret_bn = self.__secret_key.secret_scalar()._backend_bignum
r_int, s_int = openssl.ecdsa_sign(curve=CURVE,
@ -75,7 +75,7 @@ class Signature(Serializable, Deserializable):
self.r = r
self.s = s
def verify_digest(self, verifying_key: 'PublicKey', digest: 'Hash') -> bool:
def verify_digest(self, verifying_key: PublicKey, digest: Hash) -> bool:
return openssl.ecdsa_verify(curve=CURVE,
sig_r=int(self.r),
sig_s=int(self.s),