Setting ciphertext coefficients in coefficient packing

Hi,

I’m using BFVRNS to encrypt a plaintext encoded by coefficient packing. After some operations, I only need to decrypt the ciphertext coefficients at several specific positions (e.g., the 10th coefficient). Can I only send those coefficients in the ciphertext I’m interested in to reduce communication costs? Or can I set the unused coefficients (e.g., the 1st to the 9th) in the ciphertext to 0 to compress the ciphertext?

Thanks!

I don’t think that by zeroing the coefficients you will obtain a ciphertext that contains 0 in those positions… but I may be wrong.

For sure you can multiply a mask vector [0, 0, 0, 1, 0, … 0], but it depends on what you are trying to achieve I guess

@narger is correct, You won’t be able to compress the ciphertext by setting ciphertext coefficients to 0, but you can multiply by a mask vector. However, multiplying by a mask vector will not compress the ciphertext. It is possible to compress the ciphertext with other methods, but we have not added support for this yet for BFVRNS. We just created the issue on GitHub. Add BFV support for Compress · Issue #341 · openfheorg/openfhe-development · GitHub

Thanks for the reply, but I think you misunderstood my point. For decryption in BFV, let’s say it’s pt = cv[0] + cv[1] * s (openfhe-development/rns-pke.cpp at main · openfheorg/openfhe-development · GitHub).

If we only need part of the coefficients in pt, I think we can simply set the unused coefficients in ciphertext cv[0] to zero, or just drop those to reduce communication. I agree that we cannot change ciphertext cv[1]. Please correct me if I make anything wrong here.

I think you are assuming that each coefficient is somehow correlated to each value in the ciphertext (as value = f(coefficient) ), but I don’t think is like that

What do you mean by “value in the ciphertext” here? I’m using coefficient packing and I just need to get the 10th coefficient of the pt above. I don’t think I’m making any unreasonable assumptions. I know that this is doable in seal (OpenCheetah/hom_fc_ss.cc at main · Alibaba-Gemini-Lab/OpenCheetah · GitHub) and I’m trying to switch to openfhe to get better performance.

I see, yes you can set coefficients of cv[0] to 0. We don’t have an API to do this, but you can manually set them. You can call

DCRTPoly c0 = ciphertext->GetElements()[0];
c0.SetFormat(Format::COEFFICIENT);

And you need to iterate through all CRT moduli:

for (size_t i = 0; i < c0.GetNumOfElements(); i++) {
    NativePoly a = c0.GetElementAtIndex(i);
    // Set 0th coefficient to 0.
    a[0] = 0;
}