Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting logs of errors from SEAL #124

Open
arituerto opened this issue Sep 20, 2024 · 5 comments
Open

Getting logs of errors from SEAL #124

arituerto opened this issue Sep 20, 2024 · 5 comments
Labels
question Further information is requested

Comments

@arituerto
Copy link

arituerto commented Sep 20, 2024

Type
I'm having issues when encrypting vectors that I cannot reproduce in my development machine.

Describe
I have a small piece of software that used Python-SEAL. Everything works fine but when I move to a different machine software stops working, I cannot create keys nor encrypt a vector when I provide keys created in my machine. Software simply stops without any error and I cannot reproduce in my dev machine. Is there any way of enabling logs for SEAL?

Thanks in advance!

@arituerto arituerto added the question Further information is requested label Sep 20, 2024
@Huelse
Copy link
Owner

Huelse commented Sep 21, 2024

Can you provide a code case and the system environment? This library should throw std errors like in C++.

@arituerto
Copy link
Author

I have a class that controls all SEAL related stuff. There, all the seal objects are created, initialized so they can be used when needed:

params = seal.EncryptionParameters(seal_scheme_type)
params.set_poly_modulus_degree(poly_modulus_degree)
if coeff_modulus is not None:
    params.set_coeff_modulus(coeff_modulus)
else:
    params.set_coeff_modulus(
        seal.CoeffModulus.BFVDefault(poly_modulus_degree))
if plain_modulus is not None:
    params.set_plain_modulus(plain_modulus)
else:
    params.set_plain_modulus(
        seal.PlainModulus.Batching(poly_modulus_degree, plain_modulus_bit_size))
self.__context = context = seal.SEALContext(params)
logging.info("Context created and set")
self.__batch_encoder = seal.BatchEncoder(self.__context)
logging.info("BatchEncoder created")
self.__evaluator = seal.Evaluator(self.__context)
logging.info("Evaluator created")

Encryptor is initialized with a public key read from file:

self.__encryptor = seal.Encryptor(self.__context, public_key)

Process method is the one doing the encryption, it receives a vector and tries to encrypt it

def process(self, vector_id:  np.Array):
        pod_vector = [np.int64(0.) for i in range(
            int(self.__batch_encoder.slot_count() / 2))]
        for i, v in enumerate(vector_id):
            pod_vector[i] = np.int64(self.__precision * v)
        logging.debug("Pod vector computed")
        plain_vector = self.__batch_encoder.encode(pod_vector)
        logging.debug("Vector encoded")
        encrypted_vector = self.__encryptor.encrypt(plain_vector)
        logging.debug("Vector encrypted")

Last log is never reached, program stops with no message, no raised exception, nothing.

I have tested the code both in linux (ubuntu 22.04 and windows 11) and it works in both (Processor: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz 2.42 GHz). The computer where things are failing is an i7 with the same windows.

I checked SEAL code and didn't find any std error code, just throwing c++ exceptions.

@arituerto
Copy link
Author

arituerto commented Oct 3, 2024

Hello. Do you have any idea about what's happening with the c++ logs or the exceptions? Something that I can try?
Thanks in advance

@Huelse
Copy link
Owner

Huelse commented Oct 11, 2024

Sorry for the late reply, I do not observe any specific issues, how the SEALContext be created? can you impl it without the class wrapper?

@arituerto
Copy link
Author

I suspect that the issue is related with the SEAL compilation failing when trying to use wheel to install in a different machine. When I recompile and reinstall SEAL-Python everything works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants