I use MakePackedPlaintext function to create a plaintext. I give a vector that contains 100000 integers as an input to MakePackedPlaintext function. After that, I try to encrypt this plaintext. However, I get an error (segmentation fault). I also try to create a plaintext with less size. For example, I got no error for a vector that contains 10000 integers. Is there a limited number of elements that a plaintext is able to contain or do you have any other comment for the reason of this segmentation fault?

Yes, there is a limit on the vector size, and that depends on the scheme and the cryptographic parameters used.
Which scheme are you using? BFV, BGV, or CKKS?

Theoretically, the maximum number of slots one BFV ciphertext may contain is equal to the underlying ring dimension N. Do print N in your main program after initializing the cryptocontext. You can use the line below to print the ring dimension:

You can increase N by increasing the multiplicative depth via parameters.SetMultiplicativeDepth(depth);. Or you can break down your input data into multiple vectors of size less than or equal to N and use multiple ciphertexts instead.

Note that increasing N unnecessarily may degrade the performance as this will amplify low-level FHE data structures and induce more complex computations.

Also, note that to get the maximum number of slots in BFV, your plaintext modulus should be a prime integer that satisfies the following condition: 1 \equiv t \mod 2N

Hi @guliz , could you submit an issue (bug report) about this? MakePackedPlaintext() should probably check if you are trying to encrypt a vector that is too large, and throw an exception, rather than just segfaulting.

Thank you for your response. I tried to solve the problem by using different multiplicative depth and plaintext modulus. Actually, I can encrypt a vector of 100000 elements in this way.

The limit to plaintext size is based on the encoding and the size of the Ciphertext ringsize, as @Caesar showed.
In the extreme, there is a limit of machine memory for any computer program. One can always enable swap memory if your problem gets larger than your ram, however, we suggest at least 32GB if not 64GB ram for large problems.

Thank you for your reply. As I said, I can encrypt a vector of 100000 elements by increasing multiplicative depth and plaintext modulus. However, I realized that the calculations I performed on the encrypted data do not give correct results when I increase multiplicative depth too much. After I tried different parameters, I see that the following parameters for the multiplication of the ciphertexts of 100000 elements works for now.

Hi, while this may fit, We suggest that you do not try to fit everything into one ciphertext. You should work with a vector of ciphertext instead. In other words, multiple ciphertexts can be used to represent a vector of a large size.

Larger size Ciphertext (i.e. ringsize) make everything run more slowly in general. Approx NlogN slower where N is the ring size.