Partial stubs for use with the MPyC library
Project description
TNO PET Lab - secure Multi-Party Computation (MPC) - MPyC - Stubs
This package contains stubs to use for type hinting MPyC.
PET Lab
The TNO PET Lab consists of generic software components, procedures, and functionalities developed and maintained on a regular basis to facilitate and aid in the development of PET solutions. The lab is a cross-project initiative allowing us to integrate and reuse previously developed PET functionalities to boost the development of new protocols and solutions.
The package tno.mpc.mpyc.stubs is part of the TNO Python Toolbox.
Limitations in (end-)use: the content of this software package may solely be used for applications that comply with international export control laws. This implementation of cryptographic software has not been audited. Use at your own risk.
Documentation
Documentation of the tno.mpc.mpyc.stubs package can be found
here.
Install
Easily install the tno.mpc.mpyc.stubs package using pip:
$ python -m pip install tno.mpc.mpyc.stubs
Note: If you are cloning the repository and wish to edit the source code, be sure to install the package in editable mode:
$ python -m pip install -e 'tno.mpc.mpyc.stubs'
If you wish to run the tests you can use:
$ python -m pip install 'tno.mpc.mpyc.stubs[tests]'
Usage
When installing this package, the package is installed twice under two different names:
mpyc-stubstno.mpc.mpyc.stubs
The mpyc-stubs installation is named as such by the convention
<package>-stubs, which allows static type tooling to easily pick up the
additional annotations. If you only use MPyC without defining custom MPyC
coroutines (usually decorated by @asyncoro.mpc_coro and
asyncoro.mpc_coro_no_pc in the MPyC source code), then this suffices.
The package tno.mpc.mpyc.stubs provides some convenience functions that help
you with writing custom, type-checked MPyC coroutines. Most importantly, MPyC's
decorator @asyncoro.mpc_coro[_no_pc] uses the type annotations of a function
to determine its MPyC returnType. However, this may be undesirable for more
complex functions. As such, tno.mpc.mpyc.stubs provides the following
top-level import:
mpc_coro_ignoreis a decorator that replacesmpyc.asyncoro.mpc_coroand avoids interference of type annotations with runtime behaviour. The_ignorepart emphasizes that it ignores the type annotations at runtime. After stripping the type annotations, the decorator delegates the runtime logic to MPyC.
Additionally, the following top-level imports can be helpful:
returnTypereplacesmpyc.asyncoro.returnTypeor equivalentlympyc.runtime.Runtime.returnType. We encountered various Mypy issues in the past when annotatingmpyc.runtime.Runtime.returnTypeas it is appended to the class withstaticmethod()and that did not preserve type overloads. As such, we providereturnTypedirectly with proper type annotations. The function itself delegates behaviour to the MPyC counterpart.BaseSecureFloatis a type that represents secure floating point objects. It inherits frommpyc.sectypes.SecureNumber, and we make Mypy believe that bothmpyc.sectypes.SecureFloatas well as our owntno.mpc.mpyc.floating_point.SecureFloatingPointinherit from it. This way, the type annotations that we added will apply to both. If you develop MPyC coroutines that accept both secure floating point types, then you may use this class as a common ancestor.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tno_mpc_mpyc_stubs-2.11.0.tar.gz.
File metadata
- Download URL: tno_mpc_mpyc_stubs-2.11.0.tar.gz
- Upload date:
- Size: 55.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e384d5365afd526ef9ee758286f3c6fc31e89171824561581460b6aab692f39a
|
|
| MD5 |
ab9d0a449a643d08068803b0f1fa55a9
|
|
| BLAKE2b-256 |
931f52acffdff05859c0476b64c7ff3d049ba76b5e14eb7d1c7ccc6daf3a5f89
|
File details
Details for the file tno_mpc_mpyc_stubs-2.11.0-py3-none-any.whl.
File metadata
- Download URL: tno_mpc_mpyc_stubs-2.11.0-py3-none-any.whl
- Upload date:
- Size: 104.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cd24a7ea27c49ea960a15ceb92669eae7515cf7cc8d2942716b0f8b699283b9
|
|
| MD5 |
da106de747c1971751f7f807738780c6
|
|
| BLAKE2b-256 |
5b0c1176e4a6f8d54740bbfaea376561dc21eb5a0e77bc5a1b6ca3f92d466680
|