homenc / HElib

HElib is an open-source software library that implements homomorphic encryption. It supports the BGV scheme with bootstrapping and the Approximate Number CKKS scheme. HElib also includes optimizations for efficient homomorphic evaluation, focusing on effective use of ciphertext packing techniques and on the Gentry-Halevi-Smart optimizations.
https://homenc.github.io/HElib
Other
3.11k stars 760 forks source link

How can I know the size of the ciphertext? #407

Open MingliWu opened 3 years ago

MingliWu commented 3 years ago

I want to know how many bytes of the ciphertext I am going to send to another party. How can I do it?

esteffin commented 3 years ago

Hi, an estimate of the size of a serialized ciphertext object can be found here.

Consider that this estimate is absolutely experimental and subjected to change in the future.

MingliWu commented 3 years ago

Thank you for your answer, @esteffin. For the BGV_packed_arithmetic example, after testing by using Ctxt.write(), I find the ctxt file size is about 3.7MB. However, using estimateCtxtSize(context, offset) and set offset=0, I only get about 2.27MB. So it seems the offset is about 3.7-2.27=1.43MB. But the question is how can I know this offset in advance? I know it is an estimated one and can be inaccurate, but why cannot we have a function Ctxt.size() just like Ctxt.write() to know the ciphertext size without writing it into a file?