# Serialization Overhead

**URL:** <https://openfhe.discourse.group/t/serialization-overhead/1867>\
**Category:** Library Questions\
**Tags:** questions\
**Created:** [February 11, 2025, 4:26pm UTC](https://openfhe.discourse.group/t/serialization-overhead/1867 "2025-02-11T16:26:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kanjanarat](https://avatars.discourse-cdn.com/v4/letter/k/aeb1de/32.png) [@kanjanarat](https://openfhe.discourse.group/u/kanjanarat)\
**Post date:** [February 11, 2025, 4:26pm UTC](https://openfhe.discourse.group/t/serialization-overhead/1867/1 "2025-02-11T16:26:41Z")

</div>

![Screenshot 2568-02-11 at 11.21.35 PM](https://canada1.discourse-cdn.com/flex031/uploads/openfhe/original/1X/cd85102d00d7f99964d9dde3383113061849021a.png)  
 ![Screenshot 2568-02-11 at 11.21.23 PM](https://canada1.discourse-cdn.com/flex031/uploads/openfhe/original/1X/48eb5841b39acf3605bbc263146c74de48ae4492.png)

Is it normal that the size is much larger after serialize an encrypted data?  
Am I doing anything wrong?

---

<div class="post-metadata">

**Author:** ![Caesar](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/caesar/32/63_2.png) [@Caesar](https://openfhe.discourse.group/u/Caesar)\
**Post date:** [February 11, 2025, 5:01pm UTC](https://openfhe.discourse.group/t/serialization-overhead/1867/2 "2025-02-11T17:01:01Z")

</div>

You are probably printing the size of a pointer rather than the data itself. Ciphertext in OpenFHE C++ is a pointer.

---

<div class="post-metadata">

**Author:** ![kanjanarat](https://avatars.discourse-cdn.com/v4/letter/k/aeb1de/32.png) [@kanjanarat](https://openfhe.discourse.group/u/kanjanarat)\
**Post date:** [February 11, 2025, 6:08pm UTC](https://openfhe.discourse.group/t/serialization-overhead/1867/3 "2025-02-11T18:08:08Z")

</div>

Is the size of the serialized data normal?

---

<div class="post-metadata">

**Author:** ![Caesar](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/caesar/32/63_2.png) [@Caesar](https://openfhe.discourse.group/u/Caesar)\
**Post date:** [February 11, 2025, 8:34pm UTC](https://openfhe.discourse.group/t/serialization-overhead/1867/4 "2025-02-11T20:34:19Z")

</div>

Could you specify the crypto parameters such as the ring dimension, multiplicative depth, and scaling technique?

Also confirm the size unit here (Bytes, KB, or … )?

---

<div class="post-metadata">

**Author:** ![piz1va0n](https://avatars.discourse-cdn.com/v4/letter/p/ba8739/32.png) [@piz1va0n](https://openfhe.discourse.group/u/piz1va0n)\
**Post date:** [February 11, 2025, 9:57pm UTC](https://openfhe.discourse.group/t/serialization-overhead/1867/5 "2025-02-11T21:57:29Z")

</div>

Hi, I’m in the same senior project group as @kanjanarat  
To specify the crypto parameters in createCKKS(multDepth, scaleModSize, firstModSize, ringDim, batchSize):

the parameters are 17 50 60 8192 1

Serialize(Text) is return a bytes object. So, I think len(tmp) should returns the number of Bytes.

---

<div class="post-metadata">

**Author:** ![Caesar](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/caesar/32/63_2.png) [@Caesar](https://openfhe.discourse.group/u/Caesar)\
**Post date:** [February 12, 2025, 12:33am UTC](https://openfhe.discourse.group/t/serialization-overhead/1867/6 "2025-02-12T00:33:44Z")

</div>

A freshly encrypted CKKS ciphertext size (in bytes), using OpenFHE 64-bit build which is the default build, can be estimated as follows:

> bytes = 2\*N\*(d+1)\*8

where N denotes the ring dimension and d denotes the multiplicative depth.

Note that if you use the default scaling technique `FLEXIBLEAUTOEXT`, the “+1” part in the above equation becomes “+2”.

So, for your case:  
bytes = 2\*8192\*18\*8 = 2359296 which is sort of close to what your code returns. So the size of the serialized data looks normal to me.

---

<div class="post-metadata">

**Author:** ![kanjanarat](https://avatars.discourse-cdn.com/v4/letter/k/aeb1de/32.png) [@kanjanarat](https://openfhe.discourse.group/u/kanjanarat)\
**Post date:** [February 12, 2025, 2:50am UTC](https://openfhe.discourse.group/t/serialization-overhead/1867/7 "2025-02-12T02:50:00Z")

</div>

Thank you so so much!!
