Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

An implementation of Cocks' identity-based encryption (IBE) scheme

Project description

PyCocks

A Python implementation of Cocks' identity-based encryption (IBE) scheme [1].

Cocks' scheme is distinct in that it is based on the quadratic residuosity hardness problem, rather than bilinear pairings used prevalently in other IBE schemes, e.g. Boneh-Franklin [2].

As such, no dependencies are required for performing pairing-based cryptography; only gmpy2 is sufficient.

Usage

The module comprises two main classes:

  1. CocksPKG: the public key generator (PKG) responsible for the scheme's initialisation and extracting secret keys from authorised user identity values.

  2. Cocks: the user-side class for encrypting and decrypting messages using the secret key and public modulus generated by CocksPKG.

Example usage:

from cocks.cocks import CocksPKG, Cocks

cocks_pkg = CocksPKG()   # Optional param.: bit size (default = 2048)

# Extract private key, r, from an identity string; a transformed
# ID string, a, is also returned, which is required for encryption
# and decryption.
r, a = cocks_pkg.extract("User1")

cocks = Cocks(cocks_pkg.n)  # Must use same public modulus, n, from cocks_pkg
c = cocks.encrypt(b"test", a)
msg = cocks.decrypt(c, r, a)  # => b"test"

Tests

Some tests can be found in test_pycocks.py, which can be executed using pytest.

Requirements

  • gmpy2 (tested v2.0.8)

References

  1. C. Cocks, "An identity based encryption scheme based on quadratic residues", Proceedings of the IMA International Conference on Cryptography and Coding. Springer, 2001.
  2. D. Boneh and M. Franklin, "Identity-based encryption from the Weil pairing", Annual International Cryptology Conference. Springer, 2001.

Project details


Release history Release notifications

Download files

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

Files for pycocks, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size pycocks-0.0.1-py3-none-any.whl (5.5 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size pycocks-0.0.1.tar.gz (4.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page