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:
-
CocksPKG
: the public key generator (PKG) responsible for the scheme's initialisation and extracting secret keys from authorised user identity values. -
Cocks
: the user-side class for encrypting and decrypting messages using the secret key and public modulus generated byCocksPKG
.
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
- C. Cocks, "An identity based encryption scheme based on quadratic residues", Proceedings of the IMA International Conference on Cryptography and Coding. Springer, 2001.
- D. Boneh and M. Franklin, "Identity-based encryption from the Weil pairing", Annual International Cryptology Conference. Springer, 2001.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.