| 16 | PYBIND11_MAKE_OPAQUE(std::vector<std::int64_t>); |
| 17 | |
| 18 | PYBIND11_MODULE(seal, m) |
| 19 | { |
| 20 | m.doc() = "Microsoft SEAL for Python, from https://github.com/Huelse/SEAL-Python"; |
| 21 | m.attr("__version__") = "4.1.2.1"; |
| 22 | |
| 23 | py::bind_vector<std::vector<double>>( |
| 24 | m, "VectorDouble", py::buffer_protocol(), |
| 25 | SEAL_DOC("Vector container for double values used by SEAL encoders.")); |
| 26 | py::bind_vector<std::vector<std::complex<double>>>( |
| 27 | m, "VectorComplex", py::buffer_protocol(), |
| 28 | SEAL_DOC("Vector container for complex<double> values used by CKKS.")); |
| 29 | py::bind_vector<std::vector<std::uint64_t>>( |
| 30 | m, "VectorUInt", py::buffer_protocol(), |
| 31 | SEAL_DOC("Vector container for unsigned 64-bit integer slots.")); |
| 32 | py::bind_vector<std::vector<std::int64_t>>( |
| 33 | m, "VectorInt", py::buffer_protocol(), |
| 34 | SEAL_DOC("Vector container for signed 64-bit integer slots.")); |
| 35 | |
| 36 | // encryptionparams.h |
| 37 | py::enum_<scheme_type>(m, "scheme_type", SEAL_DOC("Describes the homomorphic encryption scheme to use.")) |
| 38 | .value("none", scheme_type::none) |
| 39 | .value("bfv", scheme_type::bfv) |
| 40 | .value("ckks", scheme_type::ckks) |
| 41 | .value("bgv", scheme_type::bgv); |
| 42 | |
| 43 | // serialization.h |
| 44 | py::enum_<compr_mode_type>(m, "compr_mode_type", SEAL_DOC("Compression mode used when serializing SEAL objects.")) |
| 45 | .value("none", compr_mode_type::none) |
| 46 | #ifdef SEAL_USE_ZLIB |
| 47 | .value("zlib", compr_mode_type::zlib) |
| 48 | #endif |
| 49 | #ifdef SEAL_USE_ZSTD |
| 50 | .value("zstd", compr_mode_type::zstd) |
| 51 | #endif |
| 52 | ; |
| 53 | |
| 54 | // memorymanager.h |
| 55 | py::class_<MemoryPoolHandle>( |
| 56 | m, "MemoryPoolHandle", |
| 57 | SEAL_DOC("Handle to a memory pool used by SEAL for efficient temporary allocations.")) |
| 58 | .def(py::init<>(), SEAL_DOC("Construct an uninitialized memory pool handle.")) |
| 59 | .def_static("Global", &MemoryPoolHandle::Global, SEAL_DOC("Return a handle to the global memory pool.")) |
| 60 | #ifndef _M_CEE |
| 61 | .def_static("ThreadLocal", &MemoryPoolHandle::ThreadLocal, SEAL_DOC("Return a handle to the thread-local memory pool.")) |
| 62 | #endif |
| 63 | .def_static( |
| 64 | "New", &MemoryPoolHandle::New, py::arg("clear_on_destruction") = false, |
| 65 | SEAL_DOC("Create a new independent memory pool.")) |
| 66 | .def("pool_count", &MemoryPoolHandle::pool_count, SEAL_DOC("Return the number of memory pools referenced by this handle.")) |
| 67 | .def("alloc_byte_count", &MemoryPoolHandle::alloc_byte_count, SEAL_DOC("Return the number of bytes allocated by the pool.")) |
| 68 | .def("use_count", &MemoryPoolHandle::use_count, SEAL_DOC("Return the reference count of the underlying pool.")) |
| 69 | .def("is_initialized", [](const MemoryPoolHandle &pool){ |
| 70 | return static_cast<bool>(pool); |
| 71 | }, SEAL_DOC("Return True if this handle points to an initialized memory pool.")); |
| 72 | |
| 73 | py::class_<MemoryManager>(m, "MemoryManager", SEAL_DOC("Factory for retrieving SEAL memory pools.")) |
| 74 | .def_static("GetPool", [](){ |
| 75 | return MemoryManager::GetPool(); |
nothing calls this directly
no outgoing calls
no test coverage detected