An implementation of Cocks' identity-based encryption (IBE) scheme
A Python implementation of Cocks' identity-based encryption (IBE) scheme .
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 .
As such, no dependencies are required for performing pairing-based cryptography; only gmpy2 is sufficient.
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 by
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"
Some tests can be found in
test_pycocks.py, which can be executed using
- gmpy2 (tested v2.0.8)
- 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.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|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|
|Filename, size pycocks-0.0.1.tar.gz (4.1 kB)||File type Source||Python version None||Upload date||Hashes View|