Skip to content

Commit deb846e

Browse files
committed
Add __bytes__, from_bytes() and __hash__() to docs
1 parent e48da2e commit deb846e

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

umbral-pre-python/docs/index.rst

+56
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ API reference
3838
3939
Generates a new :py:class:`SecretKey` using ``label`` as a seed.
4040

41+
.. py:method:: __bytes__() -> bytes
42+
43+
Serializes the object into a bytestring.
44+
45+
.. py:staticmethod:: from_bytes(data: bytes) -> SecretKey
46+
47+
Restores the object from a bytestring.
48+
4149
.. py:class:: PublicKey
4250
4351
An ``umbral-pre`` public key object.
@@ -46,10 +54,34 @@ API reference
4654
4755
Creates a public key corresponding to the given secret key.
4856

57+
.. py:method:: __bytes__() -> bytes
58+
59+
Serializes the object into a bytestring.
60+
61+
.. py:staticmethod:: from_bytes(data: bytes) -> PublicKey
62+
63+
Restores the object from a bytestring.
64+
65+
.. py:method:: __hash__() -> int
66+
67+
Returns a hash of self.
68+
4969
.. py:class:: Capsule
5070
5171
An encapsulated symmetric key.
5272

73+
.. py:method:: __bytes__() -> bytes
74+
75+
Serializes the object into a bytestring.
76+
77+
.. py:staticmethod:: from_bytes(data: bytes) -> Capsule
78+
79+
Restores the object from a bytestring.
80+
81+
.. py:method:: __hash__() -> int
82+
83+
Returns a hash of self.
84+
5385
.. py:function:: encrypt(pk: PublicKey, plaintext: bytes) -> Tuple[Capsule, bytes]
5486
5587
Creates a symmetric key, encrypts ``plaintext`` with it, and returns the encapsulated symmetric key along with the ciphertext. ``pk`` is the public key of the recipient.
@@ -81,6 +113,18 @@ API reference
81113
82114
Verifies the integrity of the fragment using the signing key and, optionally, the delegating and the receiving keys (if they were included in the signature in :py:func:`generate_kfrags`).
83115

116+
.. py:method:: __bytes__() -> bytes
117+
118+
Serializes the object into a bytestring.
119+
120+
.. py:staticmethod:: from_bytes(data: bytes) -> KeyFrag
121+
122+
Restores the object from a bytestring.
123+
124+
.. py:method:: __hash__() -> int
125+
126+
Returns a hash of self.
127+
84128
.. py:class:: CapsuleFrag
85129
86130
A reencrypted fragment of an encapsulated symmetric key.
@@ -89,6 +133,18 @@ API reference
89133
90134
Verifies the integrity of the fragment.
91135

136+
.. py:method:: __bytes__() -> bytes
137+
138+
Serializes the object into a bytestring.
139+
140+
.. py:staticmethod:: from_bytes(data: bytes) -> CapsuleFrag
141+
142+
Restores the object from a bytestring.
143+
144+
.. py:method:: __hash__() -> int
145+
146+
Returns a hash of self.
147+
92148

93149
Indices and tables
94150
==================

0 commit comments

Comments
 (0)