EdwardDixon / PyBV

A Python Implementation of the BV Homomorphic Encryption Scheme

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PyBV

A Python Implementation of the BV Homomorphic Encryption Scheme

The scheme was proposed by Lauter et al. in - Can Homomorphic Encryption be Practical? (https://eprint.iacr.org/2011/405.pdf) which was a variant of the Some-what homomorphic encryption scheme given by Brakerski et al. in - Fully Homomorphic Encryption from Ring-LWE and Security for Key Dependent Messages (http://www.wisdom.weizmann.ac.il/~zvikab/localpapers/IdealHom.pdf).

The API can be imported using the command "import BV". It currently supports the following functions and classes:

Setup

OSX

brew cask install xquartz
brew install pari
brew link pari # optional
brew install swig
sh build.sh

Functions:

pari_init(pari_size, max_prime)

pari_init() is the function that needs to be called before dealing with this API. On importing the module, the module executes this statement automatically. pari_size defines the size of stack we'll be using, and max_prime defines the pre computed prime table. By default, pari_size is set to 2000000000, and max_prime is set to 2. Arguments: pari_size (int), max_prime (int)

pari_close()

pari_close() function has to be called at the end of each program to clear the memory used.

Classes:

pari_GEN

This class abstracts the GEN variable in C++, making it available through python interface. The class is compatible with +, *, /, -, __getitem__ , %, and print.
  • Class Data:

    1. value (GEN)
  • __init__(self, x) The constructor converts x to a GEN variable. Arguments: x(int)

parameters

  • Class Data:
    1. n, Q, sigma (ints)
    2. q, t, F (pari_GEN)

secret_key

  • Class Data:

    1. sk (pari_GEN)
    2. params (parameters)
  • __init__(self, sk = None, parmas = None)
    The constructor initiates class data. Arguments: sk (pari_GEN), params (parameters)

  • decrypt(self, ct)
    decrypt() method returns the plaintext (pari_GEN) encrypted in ciphertext ct. Arguments: ct (pari_GEN)

  • serialize(self)
    TO BE IMPLEMENTED

public_key

  • Class Data:

    1. pk (pari_GEN)
    2. params (parameters*)
  • __init__(self, pk = None, params = None)
    The constructor initiates the class data. Arguments: pk (pari_GEN), params (parameters*)

  • encrypt(self, pt)
    encrypt() method returns the ciphertext (pari_GEN) which encrypts plaintext pt. Arguments: pt (pari_GEN)

  • serialize(self)
    TO BE IMPLEMENTED

key_pair

  • Class Data:
    1. sk (secret_key)
    2. pk (public_key)

key_gen

  • generate_key(self, n, Q, T, sigma)
    generate_key() method returns the keys, which is of type key_pair. Arguments: n (int), Q (int), T (int), sigma (int)

  • deserialize(self)
    TO BE IMPLEMENTED

ciphertext

The class is compatible with '+', '*', and '-' operators. It also supports mulitplication with plaintext (int) and batching.
  • Class Data:

    1. value (pari_GEN)
    2. pk (public_key*)
  • __init__(self, plaintext = None, pk)
    The plaintext variable is either an int variable, or it is an int_list variable. The size of list has to be less than the degree of polynomials (paramter n) in the polynomial ring. The constuctor method takes two arguments: plaintext (int or int_list), pk (public_key*)

  • decrypt(self, sk)
    decrypt() method returns the decrypted ciphertext which is pari_GEN variable. Arguments: sk (secret_key*)

About

A Python Implementation of the BV Homomorphic Encryption Scheme

License:Apache License 2.0


Languages

Language:C++ 81.9%Language:Python 17.1%Language:HTML 1.0%Language:Shell 0.0%