diff --git a/examples/binfhe/eval-function.py b/examples/binfhe/eval-function.py new file mode 100644 index 0000000..27ea838 --- /dev/null +++ b/examples/binfhe/eval-function.py @@ -0,0 +1,41 @@ +from openfhe import * + +## Sample Program: Step 1: Set CryptoContext + +cc = BinFHEContext() +cc.GenerateBinFHEContext(STD128, True, 12) + +## Sample Program: Step 2: Key Generation +# Generate the secret key +sk = cc.KeyGen() + +print("Generating the bootstrapping keys...") + +# Generate the bootstrapping keys (refresh and switching keys) +cc.BTKeyGen(sk) + +print("Completed the key generation.") + +## Sample Program: Step 3: Create the to-be-evaluated funciton and obtain its corresponding LUT +p = cc.GetMaxPlaintextSpace() # Obtain the maximum plaintext space + +# Initialize Function f(x) = x^3 % p +def fp(m,p1): + if m= 3)}. Evaluated sign: {result}") diff --git a/src/lib/binfhe_bindings.cpp b/src/lib/binfhe_bindings.cpp index 3b85085..eb141b5 100644 --- a/src/lib/binfhe_bindings.cpp +++ b/src/lib/binfhe_bindings.cpp @@ -113,10 +113,14 @@ void bind_binfhe_enums(py::module &m) { py::enum_(m, "BINFHE_OUTPUT") .value("INVALID_OUTPUT", BINFHE_OUTPUT::INVALID_OUTPUT) .value("FRESH", BINFHE_OUTPUT::FRESH) - .value("BOOTSTRAPPED", BINFHE_OUTPUT::BOOTSTRAPPED); + .value("BOOTSTRAPPED", BINFHE_OUTPUT::BOOTSTRAPPED) + .value("LARGE_DIM", BINFHE_OUTPUT::LARGE_DIM) + .value("SMALL_DIM", BINFHE_OUTPUT::SMALL_DIM); m.attr("INVALID_OUTPUT") = py::cast(BINFHE_OUTPUT::INVALID_OUTPUT); m.attr("FRESH") = py::cast(BINFHE_OUTPUT::FRESH); m.attr("BOOTSTRAPPED") = py::cast(BINFHE_OUTPUT::BOOTSTRAPPED); + m.attr("LARGE_DIM") = py::cast(BINFHE_OUTPUT::LARGE_DIM); + m.attr("SMALL_DIM") = py::cast(BINFHE_OUTPUT::SMALL_DIM); py::enum_(m, "BINGATE") .value("OR", BINGATE::OR)