Giter Club home page Giter Club logo

Comments (4)

marcwil avatar marcwil commented on May 10, 2024 1

Could you paste a minimal example code snippet? I'm not sure what you mean by putting ciphertext first / loaded ciphertext.

from pyfhel.

767472021 avatar 767472021 commented on May 10, 2024

Code_demo:

ctxt1 = HE.encryptInt(integer1)
ctxt1.save("ctxt")
loaded = PyCtxt()
loaded.load("ctxt")
sum1 = loaded + loaded
print(HE.decryptInt(sum1))

Bug:
AttributeError: 'NoneType' object has no attribute 'add'

from pyfhel.

marcwil avatar marcwil commented on May 10, 2024

Yeah I see.

The __add__ function that is used when applying the + operator uses an internal reference to the Pyfhel object it is associated with, _pyfhel.

By saving a ciphertext to a file, the Pyfhel reference is lost. This is okay, because after restoring the ciphertext from the file, the Pyfhel object might have been restored from a file as well and the old reference won't be correct anymore.

We have two ways of solving this problem:

  1. Using Pyfhel.add instead of Ciphertext's + operator
ctxt1 = HE.encryptInt(integer1)
ctxt1.save("ctxt")
loaded = PyCtxt()
loaded.load("ctxt")
sum1 = HE.add(loaded, loaded)
print(HE.decryptInt(sum1))
  1. Manually assigning the _pyfhel reference
ctxt1 = HE.encryptInt(integer1)
ctxt1.save("ctxt")
loaded = PyCtxt()
loaded.load("ctxt")
loaded._pyfhel = HE
sum1 = loaded + loaded
print(HE.decryptInt(sum1))

I hope this helps and I agree that this is not made as clear as it should be by the documentation.

from pyfhel.

767472021 avatar 767472021 commented on May 10, 2024

Thank you very much for helping me solve the big problem.

from pyfhel.

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.