@@ -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}
@@ -179,18 +182,26 @@ void bind_binfhe_context(py::module &m) {
179182 binfhe_BTKeyGen_docs,
180183 py::arg (" sk" ),
181184 py::arg (" keygenMode" ) = SYM_ENCRYPT)
182- .def (" Encrypt" , &binfhe_EncryptWrapper,
183- binfhe_Encrypt_docs,
185+ .def (" Encrypt" ,
186+ [](BinFHEContext& self, ConstLWEPrivateKey sk, const LWEPlaintext& m, BINFHE_OUTPUT output, LWEPlaintextModulus p, uint64_t mod) {
187+ return self.Encrypt (sk, m, output, p, NativeInteger (mod));
188+ },
184189 py::arg (" sk" ),
185190 py::arg (" m" ),
186191 py::arg (" output" ) = BOOTSTRAPPED,
187192 py::arg (" p" ) = 4 ,
188- py::arg (" mod" ) = 0 )
189- .def (" Decrypt" , &binfhe_DecryptWrapper,
190- binfhe_Decrypt_docs,
193+ py::arg (" mod" ) = 0 ,
194+ py::doc (binfhe_Encrypt_docs))
195+ .def (" Decrypt" ,
196+ [](BinFHEContext& self, ConstLWEPrivateKey sk, ConstLWECiphertext ct, LWEPlaintextModulus p) {
197+ LWEPlaintext result;
198+ self.Decrypt (sk, ct, &result, p);
199+ return result;
200+ },
191201 py::arg (" sk" ),
192202 py::arg (" ct" ),
193- py::arg (" p" ) = 4 )
203+ py::arg (" p" ) = 4 ,
204+ py::doc (binfhe_Decrypt_docs))
194205 .def (" EvalBinGate" ,
195206 py::overload_cast<BINGATE, ConstLWECiphertext&, ConstLWECiphertext&, bool >(&BinFHEContext::EvalBinGate, py::const_),
196207 binfhe_EvalBinGate_docs,
@@ -206,10 +217,22 @@ void bind_binfhe_context(py::module &m) {
206217 .def (" EvalNOT" , &BinFHEContext::EvalNOT,
207218 binfhe_EvalNOT_docs,
208219 py::arg (" ct" ))
209- .def (" Getn" , &GetnWrapper)
210- .def (" Getq" , &GetqWrapper)
211- .def (" GetMaxPlaintextSpace" , &GetMaxPlaintextSpaceWrapper)
212- .def (" GetBeta" , &GetBetaWrapper)
220+ .def (" Getn" ,
221+ [](BinFHEContext& self) {
222+ return self.GetParams ()->GetLWEParams ()->Getn ();
223+ })
224+ .def (" Getq" ,
225+ [](BinFHEContext& self) {
226+ return self.GetParams ()->GetLWEParams ()->Getq ().ConvertToInt <uint64_t >();
227+ })
228+ .def (" GetMaxPlaintextSpace" ,
229+ [](BinFHEContext& self) {
230+ return self.GetMaxPlaintextSpace ().ConvertToInt <uint64_t >();
231+ })
232+ .def (" GetBeta" ,
233+ [](BinFHEContext& self) {
234+ return self.GetBeta ().ConvertToInt <uint64_t >();
235+ })
213236 .def (" EvalDecomp" , &BinFHEContext::EvalDecomp,
214237 binfhe_EvalDecomp_docs,
215238 py::arg (" ct" ))
@@ -221,15 +244,22 @@ void bind_binfhe_context(py::module &m) {
221244 binfhe_GenerateLUTviaFunction_docs,
222245 py::arg (" f" ),
223246 py::arg (" p" ))
224- .def (" EvalFunc" , &EvalFuncWrapper,
225- binfhe_EvalFunc_docs,
247+ .def (" EvalFunc" ,
248+ [](BinFHEContext& self, ConstLWECiphertext& ct, const std::vector<uint64_t >& LUT) {
249+ std::vector<NativeInteger> nativeLUT;
250+ nativeLUT.reserve (LUT.size ());
251+ for (auto value : LUT) {
252+ nativeLUT.emplace_back (value);
253+ }
254+ return self.EvalFunc (ct, nativeLUT);
255+ },
226256 py::arg (" ct" ),
227- py::arg (" LUT" ))
257+ py::arg (" LUT" ),
258+ py::doc (binfhe_EvalFunc_docs))
228259 .def (" EvalSign" , &BinFHEContext::EvalSign,
229260 binfhe_EvalSign_docs,
230261 py::arg (" ct" ),
231262 py::arg (" schemeSwitch" ) = false )
232- .def (" EvalNOT" , &BinFHEContext::EvalNOT)
233263 .def (" EvalConstant" , &BinFHEContext::EvalConstant)
234264 .def (" ClearBTKeys" , &BinFHEContext::ClearBTKeys)
235265 .def (" Bootstrap" , &BinFHEContext::Bootstrap, py::arg (" ct" ), py::arg (" extended" ) = false )
0 commit comments