Giter Site home page Giter Site logo

fe-inner-product's Introduction

PyFE

Python implementation of some existing functional encryption schemes supporting the inner product functionality.

NOTE: This implementation is only meant for educational and research purposes.

Installation

This library uses Charm - a framework for rapidly prototyping cryptosystems. To install Charm, first verify that you have installed the following dependencies:

After that proceed with Charm installation. NOTE: You may encounter problems when installing Charm with Python version higher than 3.6. Therefore, it is recommended to install Python 3.6 and run Charm's configure script, ./configure.sh, with the --python=PATH option, where path points to your installation of Python3.6.

Finally, create a virtualenv from the provided Pipfile, by running pipenv install --site-packages (the --site-packages option will include Charm in the environment).

How to use

Each scheme consists of four basic methods:

  • set_up - generates all parameters needed for the scheme and returns the pair of master public key and master secret key;
  • get_functional_key - returns the key allowing for calculation of inner product of provided vector and some ciphertext encrypting other vector;
  • encrypt - encrypts the provided vector;
  • decrypt - recovers inner product of two vectors from provided vector, its functional key and ciphertext encrypting the other vector.

All methods are implemented as independent script methods and so can be used independently on different machines if we just provide the correct keys.

Example usage

import src.inner_product.single_input_fe.ddh_pk_ip.ddh_pk_ip

fe = src.inner_product.single_input_fe.ddh_pk_ip.ddh_pk_ip

# generate master public and secret key
mpk, msk = fe.set_up(security_parameter=1024, vector_length=10)

# get functional key for some vector y
y = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
func_key = fe.get_functional_key(mpk=mpk, msk=msk, y=y)

# encrypt some vector x
x = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
x_ciphertext = fe.encrypt(mpk=mpk, x=x)

# decrypt inner product of x and y lying within some limit
inner_product = fe.decrypt(mpk=mpk, ciphertext=x_ciphertext, sk_y=func_key, y=y, limit=200)

Schemes

Currently implemented schemes:

fe-inner-product's People

Contributors

cecyliaborek avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.