Skip to content

Commit

Permalink
Merge pull request #45 from fjarri/error-handling
Browse files Browse the repository at this point in the history
Error handling for Rust and Python
  • Loading branch information
fjarri authored May 5, 2021
2 parents 45b2b85 + deb846e commit d70d6ae
Show file tree
Hide file tree
Showing 15 changed files with 606 additions and 188 deletions.
1 change: 1 addition & 0 deletions umbral-pre-python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ crate-type = ["cdylib"]
pyo3 = { version = "0.13", features = ["extension-module"] }
umbral-pre = { path = "../umbral-pre" }
generic-array = "0.14"
hex = "0.4"
56 changes: 56 additions & 0 deletions umbral-pre-python/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ API reference
Generates a new :py:class:`SecretKey` using ``label`` as a seed.

.. py:method:: __bytes__() -> bytes
Serializes the object into a bytestring.

.. py:staticmethod:: from_bytes(data: bytes) -> SecretKey
Restores the object from a bytestring.

.. py:class:: PublicKey
An ``umbral-pre`` public key object.
Expand All @@ -46,10 +54,34 @@ API reference
Creates a public key corresponding to the given secret key.

.. py:method:: __bytes__() -> bytes
Serializes the object into a bytestring.

.. py:staticmethod:: from_bytes(data: bytes) -> PublicKey
Restores the object from a bytestring.

.. py:method:: __hash__() -> int
Returns a hash of self.

.. py:class:: Capsule
An encapsulated symmetric key.

.. py:method:: __bytes__() -> bytes
Serializes the object into a bytestring.

.. py:staticmethod:: from_bytes(data: bytes) -> Capsule
Restores the object from a bytestring.

.. py:method:: __hash__() -> int
Returns a hash of self.

.. py:function:: encrypt(pk: PublicKey, plaintext: bytes) -> Tuple[Capsule, bytes]
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.
Expand Down Expand Up @@ -81,6 +113,18 @@ API reference
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`).

.. py:method:: __bytes__() -> bytes
Serializes the object into a bytestring.

.. py:staticmethod:: from_bytes(data: bytes) -> KeyFrag
Restores the object from a bytestring.

.. py:method:: __hash__() -> int
Returns a hash of self.

.. py:class:: CapsuleFrag
A reencrypted fragment of an encapsulated symmetric key.
Expand All @@ -89,6 +133,18 @@ API reference
Verifies the integrity of the fragment.

.. py:method:: __bytes__() -> bytes
Serializes the object into a bytestring.

.. py:staticmethod:: from_bytes(data: bytes) -> CapsuleFrag
Restores the object from a bytestring.

.. py:method:: __hash__() -> int
Returns a hash of self.


Indices and tables
==================
Expand Down
Loading

0 comments on commit d70d6ae

Please sign in to comment.