Skip to main content

Implementation of Shamir secret sharing

Project description

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.

Install

Easily install the tno.mpc.encryption_schemes.shamir package using pip:

$ python -m pip install tno.mpc.encryption_schemes.shamir

If you wish to run the tests you can use:

$ python -m pip install 'tno.mpc.encryption_schemes.shamir[tests]'

Note:

A significant performance improvement can be achieved by installing the GMPY2 library.

$ python -m pip install 'tno.mpc.encryption_schemes.shamir[gmpy]'

Usage

The shamir secret sharing module can be used as follows:

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()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

File details

Details for the file tno.mpc.encryption_schemes.shamir-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: tno.mpc.encryption_schemes.shamir-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

File hashes

Hashes for tno.mpc.encryption_schemes.shamir-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 509fa06701cce743b452818a0ddb5bd9e44804b1f4b0205f9f39e3c8d49a0932
MD5 0ef442a6ae29a2663f73b3d0dcff8c0e
BLAKE2b-256 b8814000292f98515014c72bee32e4025015d8532dd995661c304f8af12f6cb2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page