Attribute-based encryption enables fine-grained control of encrypted data [SW05]. In a ciphertext-policy ABE (CP-ABE) scheme [GPSW06], for instance, ciphertexts are attached to access policies and keys are associated with sets of attributes. A key is able to recover the message hidden in a ciphertext if and only if the set of attributes satisfy the access policy. To give an example, a policy P could say (Zipcode:90210 OR City:BeverlyHills) AND (AgeGroup:18-25) and an individual A could have a key for ({Zipcode:90210}, {AgeGroup:Over65}), in which case A would not be able to decrypt any message encrypted under P. A key policy (KP-ABE) scheme, on the other hand, is the dual of CP-ABE with ciphertexts attached to attribute sets and keys associated with access policies.
I have implemented several ABE schemes in Python using the Charm framework [AGMPRGP13]. Specifically, CP-ABE schemes from [BSW07, Section 4.2], [Waters11, Section 3], [CGW15, Appendix B.2 (full version)], and [AC17, Section 3] are implemented. All implementations are based on Type-III pairings; see AC17 for details.
Some of the schemes above are bounded universe, i.e. they support an a-priori bounded number of attributes. To initialize such schemes, an additional parameter uni_size
needs to be specified. Some schemes are secure under the k-linear family of assumptions, so k must be set properly during initialization through the parameter assump_size
.
The schemes have been tested with Charm 0.43 and Python 2.7.10 on Mac OS X. Charm 0.43 can be installed from this page, or by running
pip install -r requirements.txt
Charm may not compile on Linux systems due to the incompatibility of OpenSSL versions 1.0 and 1.1. You can either install charm-crypto from the system package manager or downgrade OpenSSL to version 1.0.
Once you have Charm, just do
make && pip install . && python samples/main.py
to run the AC17 CP-ABE scheme. You can easily modify samples/main.py
to try any scheme you wish.