Metadata-Version: 2.1
Name: tno.mpc.encryption-schemes.shamir
Version: 0.1.1
Summary: Implementation of Shamir secret sharing
Home-page: https://mpc.tno.nl/
Author: TNO MPC Lab
Author-email: mpclab@tno.nl
Maintainer: TNO MPC Lab
Maintainer-email: mpclab@tno.nl
License: Apache License, Version 2.0
Download-URL: https://pypi.org/project/tno.mpc.encryption_schemes.shamir/#files
Project-URL: Documentation, https://docs.mpc.tno.nl/encryption_schemes/shamir/0.1.1
Project-URL: Source Code, https://github.com/TNO-MPC/encryption_schemes.shamir
Keywords: TNO,MPC,multi-party computation,encryption schemes,distributed,shamir,cryptosystem
Platform: any
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: Science/Research
Classifier: Typing :: Typed
Classifier: Topic :: Security :: Cryptography
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: sympy
Requires-Dist: tno.mpc.encryption-schemes.utils (>=0.8.0)
Provides-Extra: gmpy
Requires-Dist: tno.mpc.encryption-schemes.utils[gmpy] ; extra == 'gmpy'
Provides-Extra: tests
Requires-Dist: pytest ; extra == 'tests'
Requires-Dist: pytest-asyncio ; extra == 'tests'

# TNO MPC Lab - Encryption Schemes - Shamir

The TNO MPC lab consists of generic software components, procedures, and functionalities developed and maintained on a regular basis to facilitate and aid in the development of MPC solutions. The lab is a cross-project initiative allowing us to integrate and reuse previously developed MPC functionalities to boost the development of new protocols and solutions.

The package tno.mpc.encryption_schemes.shamir 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.encryption_schemes.shamir package can be found [here](https://docs.mpc.tno.nl/encryption_schemes/shamir/0.1.1).

## Install

Easily install the tno.mpc.encryption_schemes.shamir package using pip:
```console
$ python -m pip install tno.mpc.encryption_schemes.shamir
```

If you wish to run the tests you can use:
```console
$ python -m pip install 'tno.mpc.encryption_schemes.shamir[tests]'
```

### Note:
A significant performance improvement can be achieved by installing the GMPY2 library.
```console
$ python -m pip install 'tno.mpc.encryption_schemes.shamir[gmpy]'
```

## Usage

The shamir secret sharing module can be used as follows:

```python
from tno.mpc.encryption_schemes.shamir import ShamirSecretSharingScheme, ShamirShares

# Initialize a three-out-of-five secrect sharing scheme with prime 10657
# Note: the polynomial degree is one less than the number of parties needed for reconstruction
shamir_scheme = ShamirSecretSharingScheme(10657, 5, 2)
# Share a secret integer
sharing = shamir_scheme.share_secret(42)
# When receiving shares a reconstructor can be created as follows
reconstructor = ShamirShares(
    shamir_scheme, {1: sharing.shares[1], 2: sharing.shares[2], 3: sharing.shares[3]}
)
# Reconstruct the secret and check if it is the expected result
assert 42 == sharing.reconstruct_secret() == reconstructor.reconstruct_secret()
```



