Skip to main content

Threshold ElGamal cryptosystem

Project description

Threshold ElGamal cryptosystem

This is a library that provides methods for threshold encryption, decryption and DKG (distributed key generation) algorithm using the ElGamal cryptosystem. Threshold ElGamal encryption and decryption algorithms were based on Cachin's work, and the algorithm used for distributed key pair generation was based on a 1999 paper by Gennaro et al. Both algorithms use a form of secret sharing first introduced in a 1979 paper by Shamir.

This goes without saying, but you should NOT use this library in a production setting. It has not been pentested nor was any kind of exhaustive security analysis done. This library is developed primarily for demonstration of theoretic threshold schemes.

Installation

Before installing the library, make sure its dependencies are installed: pycryptodome, gmpy2 and setuptools. The library is written for Python >= 3.9.

You can then install the library via pip:

pip install threshold-elgamal

Getting started

The simplest way you can test out this library is by running its main function:

from threshold_elgamal import run_tc_scheme

res = run_tc_scheme(k=3, n=5, m=10)
if res is True:
    print("Success!")

You can also create your own threshold scheme manually, and then encrypt and decrypt a message of your choosing:

from threshold_elgamal import create_tc_scheme

message = 10
public_key, players, scheme = create_tc_scheme(k=3, n=5)
c1, c2 = scheme.encrypt(public_key, message=message)
decryption_shares = {player.id: player.get_decryption_share(c1) for player in players}
decrypted_msg = scheme.decrypt(c2, decryption_shares)

if decrypted_msg == message:
    print("Success!")

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

threshold_elgamal-0.0.13.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

threshold_elgamal-0.0.13-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file threshold_elgamal-0.0.13.tar.gz.

File metadata

  • Download URL: threshold_elgamal-0.0.13.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.0

File hashes

Hashes for threshold_elgamal-0.0.13.tar.gz
Algorithm Hash digest
SHA256 35b48815ccaa8d8ed00fe49340578cfd08faa9e5614d15755fdd560831404d35
MD5 708f9b30db4f6fa9cba37cec207a8b5f
BLAKE2b-256 b6d9af0012cb5b1777fda7d3e864062bd0ce78ff48bf99999b0451d34fe4e1c0

See more details on using hashes here.

File details

Details for the file threshold_elgamal-0.0.13-py3-none-any.whl.

File metadata

File hashes

Hashes for threshold_elgamal-0.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 b1ba3f8a292fa10f0b3c0a30b78b30138dce3b27b0ed0a18475d54d5e03eac4d
MD5 a28f358df7821018328fd1d6bda31885
BLAKE2b-256 43a6935b8084ea0b35188bda409b0af6cbd3a4efcf8fdc35ee20bbe2aa5964eb

See more details on using hashes here.

Supported by

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