Skip to main content

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


Download files

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

Source Distribution

pycocks-0.0.1.tar.gz (4.1 kB view hashes)

Uploaded Source

Built Distribution

pycocks-0.0.1-py3-none-any.whl (5.5 kB view hashes)

Uploaded Python 3

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