ibarrond / Pyfhel

PYthon For Homomorphic Encryption Libraries, perform encrypted computations such as sum, mult, scalar product or matrix multiplication in Python, with NumPy compatibility. Uses SEAL/PALISADE as backends, implemented using Cython.
https://pyfhel.readthedocs.io/
Apache License 2.0
456 stars 78 forks source link

Does Pyfhel support Batching Encode and Bootstrapping? #237

Open huyvu1404 opened 1 month ago

huyvu1404 commented 1 month ago

Please let me know if Pyfhel support Batching Encode and Bootstrapping? Thank you so much.

ShokofehVS commented 1 month ago

Here are just few examples of issues asking about bootstrapping: #216, #204, #144, #136 -> "SEAL does not provide this out of the box, meaning that Pyfhel is limited to SHE until it is merged to the bootstrapping of OpenFHE."

I saw also a comment about "batch encoding" here that Pyfhel already uses batch encoding by default. But TBH now I couldn't recall how :smile:

huyvu1404 commented 1 month ago

Here are just few examples of issues asking about bootstrapping: #216, #204, #144, #136 -> "SEAL does not provide this out of the box, meaning that Pyfhel is limited to SHE until it is merged to the bootstrapping of OpenFHE."

I saw also a comment about "batch encoding" here that Pyfhel already uses batch encoding by default. But TBH now I couldn't recall how :smile:

Thanks for your support. I'm trying to implement BFV bootstrapping, but it's too hard 😢

ShokofehVS commented 1 month ago

You can use OpenFHE written in C++ that has already implemented bootstrapping; however it is very slow compared to Pyfhel.

huyvu1404 commented 1 month ago

You can use OpenFHE written in C++ that has already implemented bootstrapping; however it is very slow compared to Pyfhel.

I want to implement logistic regression with BFV scheme but cannot find any public code to reference. Do you know any document or source code about this topic? :'(

ShokofehVS commented 1 month ago

I know about a library Concrete ML that has ML models including Linear (regression) but with TFHE scheme implemented.

Let me search a bit about BFV and I'll come back to you soon.

ShokofehVS commented 1 month ago

I found these resources just by having a quick look but you can continue by searching among Google scholar papers and project in GitHub (putting #homomorphic-encryption and #logistic-regression):

Papers (if they don't have public access to the code; you can still ask their authors):

  1. Logistic regression over encrypted data from fully homomorphic encryption
  2. Doing Real Work with FHE: The Case of Logistic Regression
  3. Secure Logistic Regression Based on Homomorphic Encryption: Design and Evaluation
  4. Implementing Linear Regression with Homomorphic Encryption
  5. Web-Based Privacy-Preserving Multicenter Medical Data Analysis Tools Via Threshold Homomorphic Encryption: Design and Development Study

Projects (I'm not sure they have implemented the bootstrapping of BFV but maybe good for you to look at them):

  1. https://github.com/MarwanNour/SEAL-FYP-Logistic-Regression (written in C++)
  2. https://github.com/datthinh1801/Homomorphic-Encryption-on-Logistic-Regression (written in C++)
huyvu1404 commented 1 month ago

I found these resources just by having a quick look but you can continue by searching among Google scholar papers and project in GitHub (putting #homomorphic-encryption and #logistic-regression):

Papers (if they don't have public access to the code; you can still ask their authors):

  1. Logistic regression over encrypted data from fully homomorphic encryption
  2. Doing Real Work with FHE: The Case of Logistic Regression
  3. Secure Logistic Regression Based on Homomorphic Encryption: Design and Evaluation
  4. Implementing Linear Regression with Homomorphic Encryption
  5. Web-Based Privacy-Preserving Multicenter Medical Data Analysis Tools Via Threshold Homomorphic Encryption: Design and Development Study

Projects (I'm not sure they have implemented the bootstrapping of BFV but maybe good for you to look at them):

  1. https://github.com/MarwanNour/SEAL-FYP-Logistic-Regression (written in C++)
  2. https://github.com/datthinh1801/Homomorphic-Encryption-on-Logistic-Regression (written in C++)

I have read those papers and github code. However, most of them use CKKS or don't have source code for me to reference. Anyway, thank you very much :((

ShokofehVS commented 1 month ago

Ah, and why so far you want to use BFV? I guess the conversion shouldn't be difficult.

TBH, I'm not sure for the current version of Pyfhel but for instance for 3.1.4, once Alberto told me that I need to rewrite things a bit e.g., turn np.sum into sums and rotations to have this conversion between schemes.

huyvu1404 commented 1 month ago

Ah, and why so far you want to use BFV? I guess the conversion shouldn't be difficult.

TBH, I'm not sure for the current version of Pyfhel but for instance for 3.1.4, once Alberto told me that I need to rewrite things a bit e.g., turn np.sum into sums and rotations to have this conversion between schemes.

Ah, I use BFV due to the requirements of my course project. There are many difficulties when using this scheme compared to CKKS :D