Python Functional Encryption Library
Project description
PyMIFE
Multi input functional encryption library for python
Installation
pip install pymife
Schemes
Single input inner product
- (Selective Secure) DDH based scheme from https://eprint.iacr.org/2015/017.pdf
- (Selective Secure) LWE based scheme from https://eprint.iacr.org/2015/017.pdf
- (Adaptive Secure) Damgard based scheme from https://eprint.iacr.org/2015/608.pdf
Multi input inner product
- (Adaptive Secure) Damgard based scheme from https://eprint.iacr.org/2017/972.pdf
Multi client inner product
- (Adaptive Secure with Random Oracle) DDH based scheme from https://eprint.iacr.org/2017/989.pdf
Note
- The implementation of these schemes are not fully optimized, recommended to use for research / testing purpose.
- More schemes will be added in the future
Usage
Single input inner product
DDH based scheme
from mife.single.ddh import FeDDH
n = 10
x = [i for i in range(n)]
y = [i + 10 for i in range(n)]
key = FeDDH.generate(n)
c = FeDDH.encrypt(x, key)
sk = FeDDH.keygen(y, key)
m = FeDDH.decrypt(c, key.get_public_key(), sk, (0, 1000))
LWE based scheme
from mife.single.lwe import FeLWE
n = 10
x = [i - 10 for i in range(n)]
y = [i for i in range(n)]
key = FeLWE.generate(n, 4, 4)
c = FeLWE.encrypt(x, key)
sk = FeLWE.keygen(y, key)
m = FeLWE.decrypt(c, key.get_public_key(), sk) % key.p
Damgard based scheme
from mife.single.damgard import FeDamgard
n = 10
x = [i for i in range(n)]
y = [i + 10 for i in range(n)]
key = FeDamgard.generate(n)
c = FeDamgard.encrypt(x, key)
sk = FeDamgard.keygen(y, key)
m = FeDamgard.decrypt(c, key.get_public_key(), sk, (0, 1000))
Multi input inner product
Damgard based scheme
from mife.multi.damgard import FeDamgardMulti
n = 3
m = 5
x = [[i + j for j in range(m)] for i in range(n)]
y = [[i - j + 10 for j in range(m)] for i in range(n)]
key = FeDamgardMulti.generate(n, m)
cs = [FeDamgardMulti.encrypt(x[i], key.get_enc_key(i)) for i in range(n)]
sk = FeDamgardMulti.keygen(y, key)
m = FeDamgardMulti.decrypt(cs, key.get_public_key(), sk, (0, 2000))
Using Curve25519
from mife.multi.damgard import FeDamgardMulti
from mife.data.curve25519 import Curve25519
n = 25
m = 25
x = [[i * 10 + j for j in range(m)] for i in range(n)]
y = [[i - j - 5 for j in range(m)] for i in range(n)]
key = FeDamgardMulti.generate(n, m, Curve25519)
cs = [FeDamgardMulti.encrypt(x[i], key.get_enc_key(i)) for i in range(n)]
sk = FeDamgardMulti.keygen(y, key)
res = FeDamgardMulti.decrypt(cs, key.get_public_key(), sk, (-10000000, 10000000))
Multi client inner product
DDH based scheme
from mife.multiclient.ddh import FeDDHMultiClient
n = 3
m = 5
x = [[i + j for j in range(m)] for i in range(n)]
y = [[i - j + 10 for j in range(m)] for i in range(n)]
tag = b"testingtag123"
key = FeDDHMultiClient.generate(n, m)
cs = [FeDDHMultiClient.encrypt(x[i], tag, key.get_enc_key(i)) for i in range(n)]
sk = FeDDHMultiClient.keygen(y, key)
m = FeDDHMultiClient.decrypt(cs, tag, key.get_public_key(), sk, (0, 2000))
Customize
All of the DDH and Damgard schemes support custom group. You can implement your own group class by extending /src/mife/data/group.py
as base class.
To use custom group, simply pass the group class to the generate
function.
This library has implemented prime order group and curve25519 group.
For MCFE-DDH scheme, you can also supply your own hash function by using the same signature as the default hash function found in /src/mife/multiclient/ddh.py
.
References
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.
Source Distribution
Built Distribution
File details
Details for the file pymife-0.0.7.tar.gz
.
File metadata
- Download URL: pymife-0.0.7.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8bd779d9d1036acd9b96962ddc90e6a66418e3cb17a71f3abc5f56f339824439 |
|
MD5 | c6cecfe76f10827246c9044f7646f707 |
|
BLAKE2b-256 | 7f6c318c4ff59706a96dad8b6fa5bc00d687759cb7b07c4bdbfcbbae32fc5389 |
File details
Details for the file pymife-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: pymife-0.0.7-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b1c20f3412c6bd33ae4a1c6b18942b369861c9463b560a117f6ca28850a9334 |
|
MD5 | dcdd9aced9455dd10eb166433839d167 |
|
BLAKE2b-256 | 07f49028d5ea70e69845f6ae28204a5d958a89c117f946b1cf4d85c51814e122 |