@@ -1305,48 +1305,135 @@ void bind_encodings(py::module &m)
13051305 return ss.str ();
13061306 });
13071307}
1308-
13091308void bind_ciphertext (py::module &m) {
1310- py::class_<CiphertextImpl<DCRTPoly>,std::shared_ptr<CiphertextImpl<DCRTPoly>>>(m, " Ciphertext" )
1309+ using CiphertextImplDCRT = CiphertextImpl<DCRTPoly>;
1310+ using CiphertextDCRT = Ciphertext<DCRTPoly>; // shared_ptr<CiphertextImpl<DCRTPoly>>
1311+
1312+ // Bind CiphertextImpl<DCRTPoly> and expose it to Python as "Ciphertext"
1313+ py::class_<CiphertextImplDCRT, std::shared_ptr<CiphertextImplDCRT>>(m, " Ciphertext" )
13111314 .def (py::init<>())
1312- .def (" __add__" , [](const Ciphertext<DCRTPoly> &a, const Ciphertext<DCRTPoly> &b) {
1315+ .def (" __add__" , [](const CiphertextDCRT &a, const CiphertextDCRT &b) {
13131316 return a + b;
13141317 },
13151318 py::is_operator (), pybind11::keep_alive<0 , 1 >())
1316- // .def(py::self + py::self);
1317- // .def("GetDepth", &CiphertextImpl<DCRTPoly>::GetDepth)
1318- // .def("SetDepth", &CiphertextImpl<DCRTPoly>::SetDepth)
1319- .def (" GetLevel" , &CiphertextImpl<DCRTPoly>::GetLevel, ctx_GetLevel_docs)
1320- .def (" SetLevel" , &CiphertextImpl<DCRTPoly>::SetLevel, ctx_SetLevel_docs,
1321- py::arg (" level" ))
1322- .def (" Clone" , &CiphertextImpl<DCRTPoly>::Clone)
1319+ .def (" GetLevel" , &CiphertextImplDCRT::GetLevel, ctx_GetLevel_docs)
1320+ .def (" SetLevel" , &CiphertextImplDCRT::SetLevel, ctx_SetLevel_docs, py::arg (" level" ))
1321+ .def (" Clone" , &CiphertextImplDCRT::Clone)
13231322 .def (" RemoveElement" , &RemoveElementWrapper, cc_RemoveElement_docs)
1324- // .def("GetHopLevel", &CiphertextImpl<DCRTPoly>::GetHopLevel)
1325- // .def("SetHopLevel", &CiphertextImpl<DCRTPoly>::SetHopLevel)
1326- // .def("GetScalingFactor", &CiphertextImpl<DCRTPoly>::GetScalingFactor)
1327- // .def("SetScalingFactor", &CiphertextImpl<DCRTPoly>::SetScalingFactor)
1328- .def (" GetSlots" , &CiphertextImpl<DCRTPoly>::GetSlots)
1329- .def (" SetSlots" , &CiphertextImpl<DCRTPoly>::SetSlots)
1330- .def (" GetNoiseScaleDeg" , &CiphertextImpl<DCRTPoly>::GetNoiseScaleDeg)
1331- .def (" SetNoiseScaleDeg" , &CiphertextImpl<DCRTPoly>::SetNoiseScaleDeg)
1332- .def (" GetCryptoContext" , &CiphertextImpl<DCRTPoly>::GetCryptoContext)
1333- .def (" GetEncodingType" , &CiphertextImpl<DCRTPoly>::GetEncodingType)
1334- .def (" GetElements" , [](const CiphertextImpl<DCRTPoly>& self) -> const std::vector<DCRTPoly>& {
1323+ .def (" GetSlots" , &CiphertextImplDCRT::GetSlots)
1324+ .def (" SetSlots" , &CiphertextImplDCRT::SetSlots)
1325+ .def (" GetNoiseScaleDeg" , &CiphertextImplDCRT::GetNoiseScaleDeg)
1326+ .def (" SetNoiseScaleDeg" , &CiphertextImplDCRT::SetNoiseScaleDeg)
1327+ .def (" GetCryptoContext" , &CiphertextImplDCRT::GetCryptoContext)
1328+ .def (" GetEncodingType" , &CiphertextImplDCRT::GetEncodingType)
1329+ .def (" GetElements" , [](const CiphertextImplDCRT& self) -> const std::vector<DCRTPoly>& {
13351330 return self.GetElements ();
1336- },
1337- py::return_value_policy::reference_internal)
1338- .def (" GetElementsMutable" , [](CiphertextImpl<DCRTPoly>& self) -> std::vector<DCRTPoly>& {
1331+ }, py::return_value_policy::reference_internal)
1332+ .def (" GetElementsMutable" , [](CiphertextImplDCRT& self) -> std::vector<DCRTPoly>& {
13391333 return self.GetElements ();
1340- },
1341- py::return_value_policy::reference_internal)
1342- .def (" SetElements" , [](CiphertextImpl<DCRTPoly>& self, const std::vector<DCRTPoly>& elems) {
1334+ }, py::return_value_policy::reference_internal)
1335+ .def (" SetElements" , [](CiphertextImplDCRT& self, const std::vector<DCRTPoly>& elems) {
13431336 self.SetElements (elems);
13441337 })
1345- .def (" SetElementsMove" , [](CiphertextImpl<DCRTPoly> & self, std::vector<DCRTPoly>&& elems) {
1338+ .def (" SetElementsMove" , [](CiphertextImplDCRT & self, std::vector<DCRTPoly>&& elems) {
13461339 self.SetElements (std::move (elems));
13471340 });
1341+
1342+ // Bind the shared_ptr alias (Ciphertext<DCRTPoly>) so it picks up the methods above
1343+ py::class_<CiphertextDCRT>(m, " _CiphertextAlias" ); // hidden helper; not necessary for users
13481344}
13491345
1346+ // void bind_ciphertext(py::module &m) {
1347+ // // using CiphertextDCRT = lbcrypto::Ciphertext<DCRTPoly>;
1348+ // // py::class_<CiphertextDCRT>(m, "Ciphertext")
1349+ // // .def(py::init<>())
1350+ // // .def("__add__", [](const CiphertextDCRT& a, const CiphertextDCRT& b) {
1351+ // // return a + b;
1352+ // // },
1353+ // // py::is_operator(), pybind11::keep_alive<0, 1>())
1354+ // // .def("GetLevel", [](const CiphertextDCRT& self) {
1355+ // // return self->GetLevel();
1356+ // // }, ctx_GetLevel_docs)
1357+ // // .def("SetLevel", [](CiphertextDCRT& self, size_t level) {
1358+ // // self->SetLevel(level);
1359+ // // }, ctx_SetLevel_docs, py::arg("level"))
1360+ // // .def("Clone", [](const CiphertextDCRT& self) {
1361+ // // return self->Clone();
1362+ // // })
1363+ // // .def("RemoveElement", [](CiphertextDCRT& self, uint32_t idx) {
1364+ // // return RemoveElementWrapper(self, idx);
1365+ // // }, cc_RemoveElement_docs)
1366+ // // .def("GetSlots", [](const CiphertextDCRT& self) {
1367+ // // return self->GetSlots();
1368+ // // })
1369+ // // .def("SetSlots", [](CiphertextDCRT& self, uint32_t slots) {
1370+ // // self->SetSlots(slots);
1371+ // // })
1372+ // // .def("GetNoiseScaleDeg", [](const CiphertextDCRT& self) {
1373+ // // return self->GetNoiseScaleDeg();
1374+ // // })
1375+ // // .def("SetNoiseScaleDeg", [](CiphertextDCRT& self, size_t val) {
1376+ // // self->SetNoiseScaleDeg(val);
1377+ // // })
1378+ // // .def("GetCryptoContext", [](const CiphertextDCRT& self) {
1379+ // // return self->GetCryptoContext();
1380+ // // })
1381+ // // .def("GetEncodingType", [](const CiphertextDCRT& self) {
1382+ // // return self->GetEncodingType();
1383+ // // })
1384+ // // .def("GetElements", [](const CiphertextDCRT& self) -> const std::vector<DCRTPoly>& {
1385+ // // return self->GetElements();
1386+ // // }, py::return_value_policy::reference_internal)
1387+ // // .def("GetElementsMutable", [](CiphertextDCRT& self) -> std::vector<DCRTPoly>& {
1388+ // // return self->GetElements();
1389+ // // }, py::return_value_policy::reference_internal)
1390+ // // .def("SetElements", [](CiphertextDCRT& self, const std::vector<DCRTPoly>& elems) {
1391+ // // self->SetElements(elems);
1392+ // // })
1393+ // // .def("SetElementsMove", [](CiphertextDCRT& self, std::vector<DCRTPoly>&& elems) {
1394+ // // self->SetElements(std::move(elems));
1395+ // // });
1396+
1397+ // // py::class_<CiphertextImpl<DCRTPoly>, std::shared_ptr<CiphertextImpl<DCRTPoly>>>(m, "Ciphertext")
1398+ // // .def(py::init<>())
1399+ // // .def("__add__", [](const Ciphertext<DCRTPoly> &a, const Ciphertext<DCRTPoly> &b) {
1400+ // // return a + b;
1401+ // // },
1402+ // // py::is_operator(), pybind11::keep_alive<0, 1>())
1403+ // // // .def(py::self + py::self);
1404+ // // // .def("GetDepth", &CiphertextImpl<DCRTPoly>::GetDepth)
1405+ // // // .def("SetDepth", &CiphertextImpl<DCRTPoly>::SetDepth)
1406+ // // .def("GetLevel", &CiphertextImpl<DCRTPoly>::GetLevel, ctx_GetLevel_docs)
1407+ // // .def("SetLevel", &CiphertextImpl<DCRTPoly>::SetLevel, ctx_SetLevel_docs,
1408+ // // py::arg("level"))
1409+ // // .def("Clone", &CiphertextImpl<DCRTPoly>::Clone)
1410+ // // .def("RemoveElement", &RemoveElementWrapper, cc_RemoveElement_docs)
1411+ // // // .def("GetHopLevel", &CiphertextImpl<DCRTPoly>::GetHopLevel)
1412+ // // // .def("SetHopLevel", &CiphertextImpl<DCRTPoly>::SetHopLevel)
1413+ // // // .def("GetScalingFactor", &CiphertextImpl<DCRTPoly>::GetScalingFactor)
1414+ // // // .def("SetScalingFactor", &CiphertextImpl<DCRTPoly>::SetScalingFactor)
1415+ // // .def("GetSlots", &CiphertextImpl<DCRTPoly>::GetSlots)
1416+ // // .def("SetSlots", &CiphertextImpl<DCRTPoly>::SetSlots)
1417+ // // .def("GetNoiseScaleDeg", &CiphertextImpl<DCRTPoly>::GetNoiseScaleDeg)
1418+ // // .def("SetNoiseScaleDeg", &CiphertextImpl<DCRTPoly>::SetNoiseScaleDeg)
1419+ // // .def("GetCryptoContext", &CiphertextImpl<DCRTPoly>::GetCryptoContext)
1420+ // // .def("GetEncodingType", &CiphertextImpl<DCRTPoly>::GetEncodingType)
1421+ // // .def("GetElements", [](const CiphertextImpl<DCRTPoly>& self) -> const std::vector<DCRTPoly>& {
1422+ // // return self.GetElements();
1423+ // // },
1424+ // // py::return_value_policy::reference_internal)
1425+ // // .def("GetElementsMutable", [](CiphertextImpl<DCRTPoly>& self) -> std::vector<DCRTPoly>& {
1426+ // // return self.GetElements();
1427+ // // },
1428+ // // py::return_value_policy::reference_internal)
1429+ // // .def("SetElements", [](CiphertextImpl<DCRTPoly>& self, const std::vector<DCRTPoly>& elems) {
1430+ // // self.SetElements(elems);
1431+ // // })
1432+ // // .def("SetElementsMove", [](CiphertextImpl<DCRTPoly>& self, std::vector<DCRTPoly>&& elems) {
1433+ // // self.SetElements(std::move(elems));
1434+ // // });
1435+ // }
1436+
13501437void bind_schemes (py::module &m){
13511438 /* Bind schemes specific functionalities like bootstrapping functions and multiparty*/
13521439 py::class_<FHECKKSRNS>(m, " FHECKKSRNS" )
0 commit comments