Coder Social home page Coder Social logo

Make PySeal Pickleable about pyseal HOT 6 CLOSED

nilslukas avatar nilslukas commented on July 24, 2024
Make PySeal Pickleable

from pyseal.

Comments (6)

nilslukas avatar nilslukas commented on July 24, 2024 2

@c3m0zturk Saving the ciphertext object to a file shouldn't be a problem. SEAL already provides a 'save' and 'load' function that take streams as parameters. I couldn't get python streams to work, but the easiest workaround would probably be to add an extra function which creates an ostream to a file and embed it into SEAL/ciphertext.cpp:

#include <fstream>
[..]
 void Ciphertext::save_to_file() const
    {
        ofstream outfile("ciphertext.bin", std::ofstream::binary);
        save(outfile);
        outfile.close();
    }
     

Then in SEAL/ciphertext.h add a function header

void save_to_file() const;

and in SEALPython/wrapper.cpp add the following line

py::class_<Ciphertext>(m, "Ciphertext")
    .def(py::init<>())
    [...] /* all other definitions */
    .def("save_to_file", (void (Ciphertext::*)()) &Ciphertext::save_to_file, "Saves ciphertext to file")

from pyseal.

cem-ozturk avatar cem-ozturk commented on July 24, 2024

Hi @NilsHendrikLukas , did you find any alternative solution to pickle or anyway to save the ciphertext objects to a file?

from pyseal.

toddstavish avatar toddstavish commented on July 24, 2024

from pyseal.

adityachivu avatar adityachivu commented on July 24, 2024

@NilsHendrikLukas Thanks for the update! @c3m0zturk and I used a similar workaround by writing a new function that takes string input for file path. We included save/load for PublicKey and SecretKey as well.

@toddstavish I have made these changes on my fork. Does it make sense to submit a PR?

from pyseal.

toddstavish avatar toddstavish commented on July 24, 2024

from pyseal.

nilslukas avatar nilslukas commented on July 24, 2024

@toddstavish I also made a PR to add Pickle serialization. It does not conflict with any native dependencies, thus it should be platform independent. I think this feature is quite important, because now with Pythons multiprocessing library one can get linear speedups depending on the number of cores (limited by the number of used plaintext moduli ofc).

from pyseal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.