Browse Source

new readme + bugfixes in examples

Rener Oliveira (Ubuntu WSL) 1 year ago
parent
commit
51f7e4b51d

+ 12 - 5
README.md

@@ -1,4 +1,4 @@
-# [Work in Progress] Official Python wrapper for OpenFHE
+# Official Python wrapper for OpenFHE
 
 ## Table of Contents
 
@@ -7,7 +7,7 @@
   - [Linux Install](#linux)
     - [Installing the .so: Conda](#conda)
     - [Installing the .so: System](#system-install)
-- [Running Examples](#examples)
+- [Running Examples](#code-examples)
 
 ## Building
 
@@ -15,10 +15,17 @@
 
 Before building, make sure you have the following dependencies installed:
 
-- [CMake](https://cmake.org/)
+- [OpenFHE](https://openfhe-development.readthedocs.io/en/latest/sphinx_rsts/intro/installation/installation.html)
 - [Python 3.6+](https://www.python.org/)
-- [pybind11](https://pybind11.readthedocs.io)
-- [OpenFHE](https://github.com/openfheorg/openfhe-development)
+- [pybind11](https://pybind11.readthedocs.io/en/stable/installing.html)
+
+You can install pybind11 by runnning:
+  
+```bash
+pip install pybind11 // or alternatively, if you use conda:
+conda install -c conda-forge pybind11
+```
+For custom installation or any other issues, please refer to the official pybind documentation in the link above.
 
 ### Linux
 

+ 2 - 2
src/pke/examples/advanced-real-numbers-128.py

@@ -1,6 +1,6 @@
 from openfhe import *
 import time # to enable TIC-TOC timing measurements
-
+ 
 def automatic_rescale_demo(scal_tech):
     if(scal_tech == ScalingTechnique.FLEXIBLEAUTO):
         print("\n\n\n ===== FlexibleAutoDemo =============\n") 
@@ -383,7 +383,7 @@ def main():
         fast_rotation_demo1()
         fast_rotation_demo2()
     else:
-        print("This demo only runs for 128-bit CKKS.\n")
+        print("This demo only runs for 128-bit CKKS.\nIf you want to test it please reinstall the OpenFHE C++ with the flag -DNATIVE_INT=128, then reinstall OpenFHE-Python.")
 
 if __name__ == "__main__":
     main()

+ 1 - 1
src/pke/examples/advanced-real-numbers.py

@@ -209,7 +209,7 @@ def fast_rotation_demo1():
     parameters = CCParamsCKKSRNS()
     parameters.SetMultiplicativeDepth(5)
     parameters.SetScalingModSize(50)
-    parameters.SetBatchSize(batchSize)
+    parameters.SetBatchSize(batch_size)
 
     cc = GenCryptoContext(parameters)
 

+ 8 - 4
src/pke/examples/function-evaluation.py

@@ -54,8 +54,12 @@ def eval_function_example():
     parameters.SetSecurityLevel(SecurityLevel.HEStd_NotSet)
     parameters.SetRingDim(1 << 10)
 
-    scaling_mod_size = 59
-    first_mod_size = 60
+    if get_native_int() == 128:
+        scaling_mod_size = 78
+        first_mod_size = 89
+    else:
+        scaling_mod_size = 50
+        first_mod_size = 60
 
     parameters.SetScalingModSize(scaling_mod_size)
     parameters.SetFirstModSize(first_mod_size)
@@ -78,8 +82,8 @@ def eval_function_example():
     plaintext = cc.MakeCKKSPackedPlaintext(input)
     ciphertext = cc.Encrypt(key_pair.publicKey, plaintext)
 
-    lower_bound = 1
-    upper_bound = 9
+    lower_bound = 0
+    upper_bound = 10
     result = cc.EvalChebyshevFunction(math.sqrt,ciphertext, lower_bound, upper_bound, poly_degree)
 
     plaintext_dec = cc.Decrypt(result, key_pair.secretKey)

+ 1 - 1
src/pke/examples/iterative-ckks-bootstrapping.py

@@ -60,7 +60,7 @@ def iterative_bootstrap_example():
     # Step 2: Precomputations for bootstrapping
     # We use a sparse packing
     num_slots = 8
-    cryptocontext.EvalBootstrapSetup(levelBudget, bsgs_dim, num_slots)
+    cryptocontext.EvalBootstrapSetup(level_budget, bsgs_dim, num_slots)
 
     # Step 3: Key generation
     key_pair = cryptocontext.KeyGen()