Skip to content

Commit c11cca4

Browse files
authored
Merge pull request #6 from Desilo/chulsoon/add_serializable_galois_keys
갈로아 키 사이즈 최적화
2 parents 8a43d9e + 7a9861e commit c11cca4

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/wrapper.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,20 @@ PYBIND11_MODULE(seal, m)
384384
})
385385
;
386386

387+
// serializable.h
388+
py::class_<Serializable<GaloisKeys>>(m, "SerializableGaloisKeys")
389+
.def("save", [](const Serializable<GaloisKeys> &gk, const std::string &path){
390+
std::ofstream out(path, std::ofstream::binary);
391+
gk.save(out);
392+
out.close();
393+
})
394+
.def("dumpb", [](const Serializable<GaloisKeys> &gk){
395+
std::stringstream out(std::ios::binary | std::ios::out);
396+
gk.save(out);
397+
return py::bytes(out.str());
398+
})
399+
;
400+
387401
// keygenerator.h
388402
py::class_<KeyGenerator>(m, "KeyGenerator")
389403
.def(py::init<const SEALContext &>())
@@ -407,7 +421,11 @@ PYBIND11_MODULE(seal, m)
407421
GaloisKeys gk;
408422
keygen.create_galois_keys(gk);
409423
return gk;
410-
});
424+
})
425+
.def("create_serializable_galois_keys", [](KeyGenerator &keygen){
426+
return keygen.create_galois_keys();
427+
})
428+
;
411429

412430
// encryptor.h
413431
py::class_<Encryptor>(m, "Encryptor")

0 commit comments

Comments
 (0)