Extract encrypted data from Ciphertext

Can I extract encrypted data from a Ciphertext using the Ciphertext.GetElement() method?

You can extract encrypted data from ciphertext using masking, that is, multiplying by a binary plaintext mask vector where you set 1 for the slots you want to extract and 0 elsewhere.

The method GetElement is used internally in the library and it returns a ring element, a mathematical object used in FHE.

1 Like

The ciphertext object is too large, so I’m trying to extract only the encrypted data portion and excluding unnecessary metadata or parameters. Are there ways to do this? is masking work?

Masking will not change the size of the ciphertext by much.
Have you tried the crypto-context method Compress?
This is usually used to compress the ciphertext before transmission or storage.

If you provide more context, we might be able to help you better.

Using the CKKS scheme, I want to store encrypted data in storage but only extract the raw encrypted data from the ciphertext object. To achieve this, I’m trying to use the GetElement method to retrieve the ring element. (Is the ring element the raw encrypted data I need?)

Then, can I push it back into the ciphertext object and perform a comparison operation?

Are there other ways to achieve this?

Normally, the ciphertexts contain two elements containing the encrypted data. But meta-data is also required to ensure the ciphertext is valid. What you are trying to do looks risky to me and totally discouraged.

Alternatively, try to instantiate your scheme with the minimal cryptographic parameters needed for your application.

Thank you so much for your advice on the masking method.