Skip to content

Commit

Permalink
Changes for the new openfhe-development release
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuponitskiy-duality committed Jul 29, 2024
1 parent 869cdd3 commit 706b783
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/pke/simple-integers-serial-bgvrns.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def main_action():
# of the keys. When deserializing a context, OpenFHE checks for the tag and
# if it finds it in the CryptoContext map, it will return the stored version.
# Hence, we need to clear the context and clear the keys.
cryptoContext.ClearEvalMultKeys()
ClearEvalMultKeys()
cryptoContext.ClearEvalAutomorphismKeys()
ReleaseAllContexts()

Expand Down
2 changes: 1 addition & 1 deletion examples/pke/simple-integers-serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def main_action():
# of the keys. When deserializing a context, OpenFHE checks for the tag and
# if it finds it in the CryptoContext map, it will return the stored version.
# Hence, we need to clear the context and clear the keys.
cryptoContext.ClearEvalMultKeys()
ClearEvalMultKeys()
cryptoContext.ClearEvalAutomorphismKeys()
ReleaseAllContexts()

Expand Down
2 changes: 1 addition & 1 deletion examples/pke/simple-real-numbers-serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ def serverSetupAndWrite(multDepth, scaleModSize, batchSize):

def clientProcess():
# clientCC = CryptoContext()
# clientCC.ClearEvalMultKeys()
# clientCC.ClearEvalAutomorphismKeys()
ReleaseAllContexts()
ClearEvalMultKeys()

clientCC, res = DeserializeCryptoContext(datafolder + ccLocation, BINARY)
if not res:
Expand Down
3 changes: 3 additions & 0 deletions src/include/pke/cryptocontext_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,7 @@ const double GetScalingFactorRealWrapper(CryptoContext<DCRTPoly>& self, uint32_t
const uint64_t GetModulusCKKSWrapper(CryptoContext<DCRTPoly>& self);
const ScalingTechnique GetScalingTechniqueWrapper(CryptoContext<DCRTPoly>& self);
const usint GetDigitSizeWrapper(CryptoContext<DCRTPoly>& self);

void ClearEvalMultKeysWrapper();

#endif // OPENFHE_CRYPTOCONTEXT_BINDINGS_H
12 changes: 6 additions & 6 deletions src/lib/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,10 +715,6 @@ void bind_crypto_context(py::module &m)
.def("FindAutomorphismIndices", &CryptoContextImpl<DCRTPoly>::FindAutomorphismIndices,
cc_FindAutomorphismIndices_docs,
py::arg("idxList"))
.def_static(
"ClearEvalMultKeys", []()
{ CryptoContextImpl<DCRTPoly>::ClearEvalMultKeys(); },
cc_ClearEvalMultKeys_docs)
.def_static(
"InsertEvalSumKey", &CryptoContextImpl<DCRTPoly>::InsertEvalSumKey,
cc_InsertEvalSumKey_docs,
Expand All @@ -727,7 +723,8 @@ void bind_crypto_context(py::module &m)
.def_static(
"InsertEvalMultKey", &CryptoContextImpl<DCRTPoly>::InsertEvalMultKey,
cc_InsertEvalMultKey_docs,
py::arg("evalKeyVec"))
py::arg("evalKeyVec"),
py::arg("keyTag") = "")
.def_static(
"ClearEvalAutomorphismKeys", []()
{ CryptoContextImpl<DCRTPoly>::ClearEvalAutomorphismKeys(); },
Expand Down Expand Up @@ -835,8 +832,11 @@ void bind_crypto_context(py::module &m)
py::arg("params"));
m.def("GenCryptoContext", &GenCryptoContext<CryptoContextCKKSRNS>,
py::arg("params"));
m.def("ReleaseAllContexts", &CryptoContextFactory<DCRTPoly>::ReleaseAllContexts);

m.def("GetAllContexts", &CryptoContextFactory<DCRTPoly>::GetAllContexts);

m.def("ReleaseAllContexts", &CryptoContextFactory<DCRTPoly>::ReleaseAllContexts);
m.def("ClearEvalMultKeys", &ClearEvalMultKeysWrapper);
}

int get_native_int(){
Expand Down
4 changes: 4 additions & 0 deletions src/lib/pke/cryptocontext_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,7 @@ const ScalingTechnique GetScalingTechniqueWrapper(CryptoContext<DCRTPoly> & self
}

}

void ClearEvalMultKeysWrapper() {
CryptoContextImpl<DCRTPoly>::ClearEvalMultKeys();
}
6 changes: 3 additions & 3 deletions tests/test_serial_cc.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_serial_cryptocontext(tmp_path):
LOGGER.debug("The cryptocontext has been serialized.")
assert fhe.SerializeToFile(str(tmp_path / "ciphertext1.json"), ciphertext1, fhe.JSON)

cryptoContext.ClearEvalMultKeys()
fhe.ClearEvalMultKeys()
cryptoContext.ClearEvalAutomorphismKeys()
fhe.ReleaseAllContexts()

Expand Down Expand Up @@ -117,7 +117,7 @@ def test_serial_cryptocontext_str(mode):
automorphismKey_ser = fhe.SerializeEvalAutomorphismKeyString(mode, "")
LOGGER.debug("The rotation evaluation keys have been serialized.")

cryptoContext.ClearEvalMultKeys()
fhe.ClearEvalMultKeys()
cryptoContext.ClearEvalAutomorphismKeys()
fhe.ReleaseAllContexts()

Expand Down Expand Up @@ -213,4 +213,4 @@ def rotate_vector(vector, rotation):
rotated = [0] * rotation + vector[:n - rotation]
else:
rotated = vector
return rotated
return rotated

0 comments on commit 706b783

Please sign in to comment.