Skip to content

Commit 6dc42aa

Browse files
binfhe_bindings cleanup
1 parent d70f780 commit 6dc42aa

File tree

3 files changed

+20
-41
lines changed

3 files changed

+20
-41
lines changed

src/include/binfhe/binfhecontext_wrapper.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,6 @@ LWEPlaintext binfhe_DecryptWrapper(BinFHEContext &self,
5151
ConstLWECiphertext ct,
5252
LWEPlaintextModulus p);
5353

54-
uint32_t GetnWrapper(BinFHEContext &self);
55-
56-
const uint64_t GetqWrapper(BinFHEContext &self) ;
57-
58-
const uint64_t GetMaxPlaintextSpaceWrapper(BinFHEContext &self);
59-
60-
const uint64_t GetBetaWrapper(BinFHEContext &self);
61-
62-
const uint64_t GetLWECiphertextModulusWrapper(LWECiphertext &self);
63-
6454
std::vector<uint64_t> GenerateLUTviaFunctionWrapper(BinFHEContext &self, py::function f, uint64_t p);
6555

6656
NativeInteger StaticFunction(NativeInteger m, NativeInteger p);

src/lib/binfhe/binfhecontext_wrapper.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,31 +54,6 @@ LWEPlaintext binfhe_DecryptWrapper(BinFHEContext &self,
5454
return result;
5555
}
5656

57-
uint32_t GetnWrapper(BinFHEContext &self)
58-
{
59-
return self.GetParams()->GetLWEParams()->Getn();
60-
}
61-
62-
const uint64_t GetqWrapper(BinFHEContext &self)
63-
{
64-
return self.GetParams()->GetLWEParams()->Getq().ConvertToInt<uint64_t>();
65-
}
66-
67-
const uint64_t GetMaxPlaintextSpaceWrapper(BinFHEContext &self)
68-
{
69-
return self.GetMaxPlaintextSpace().ConvertToInt<uint64_t>();
70-
}
71-
72-
const uint64_t GetBetaWrapper(BinFHEContext &self)
73-
{
74-
return self.GetBeta().ConvertToInt<uint64_t>();
75-
}
76-
77-
const uint64_t GetLWECiphertextModulusWrapper(LWECiphertext &self)
78-
{
79-
return self->GetModulus().ConvertToInt<uint64_t>();
80-
}
81-
8257
// Define static variables to hold the state
8358
py::function* static_f = nullptr;
8459

src/lib/binfhe_bindings.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,10 @@ void bind_binfhe_ciphertext(py::module &m) {
147147
py::class_<LWECiphertextImpl, std::shared_ptr<LWECiphertextImpl>>(m, "LWECiphertext")
148148
.def(py::init<>())
149149
.def("GetLength", &LWECiphertextImpl::GetLength)
150-
.def("GetModulus", &GetLWECiphertextModulusWrapper)
150+
.def("GetModulus",
151+
[](LWECiphertext& self) {
152+
return self->GetModulus().ConvertToInt<uint64_t>();
153+
})
151154
.def(py::self == py::self)
152155
.def(py::self != py::self);
153156
}
@@ -206,10 +209,22 @@ void bind_binfhe_context(py::module &m) {
206209
.def("EvalNOT", &BinFHEContext::EvalNOT,
207210
binfhe_EvalNOT_docs,
208211
py::arg("ct"))
209-
.def("Getn", &GetnWrapper)
210-
.def("Getq", &GetqWrapper)
211-
.def("GetMaxPlaintextSpace", &GetMaxPlaintextSpaceWrapper)
212-
.def("GetBeta", &GetBetaWrapper)
212+
.def("Getn",
213+
[](BinFHEContext& self) {
214+
return self.GetParams()->GetLWEParams()->Getn();
215+
})
216+
.def("Getq",
217+
[](BinFHEContext& self) {
218+
return self.GetParams()->GetLWEParams()->Getq().ConvertToInt<uint64_t>();
219+
})
220+
.def("GetMaxPlaintextSpace",
221+
[](BinFHEContext& self) {
222+
return self.GetMaxPlaintextSpace().ConvertToInt<uint64_t>();
223+
})
224+
.def("GetBeta",
225+
[](BinFHEContext& self) {
226+
return self.GetBeta().ConvertToInt<uint64_t>();
227+
})
213228
.def("EvalDecomp", &BinFHEContext::EvalDecomp,
214229
binfhe_EvalDecomp_docs,
215230
py::arg("ct"))
@@ -229,7 +244,6 @@ void bind_binfhe_context(py::module &m) {
229244
binfhe_EvalSign_docs,
230245
py::arg("ct"),
231246
py::arg("schemeSwitch") = false)
232-
.def("EvalNOT", &BinFHEContext::EvalNOT)
233247
.def("EvalConstant", &BinFHEContext::EvalConstant)
234248
.def("ClearBTKeys", &BinFHEContext::ClearBTKeys)
235249
.def("Bootstrap", &BinFHEContext::Bootstrap, py::arg("ct"), py::arg("extended") = false)

0 commit comments

Comments
 (0)