# RAM consumption of CKKS

**URL:** <https://openfhe.discourse.group/t/ram-consumption-of-ckks/2100>\
**Category:** Library Questions\
**Created:** [July 17, 2025, 11:06am UTC](https://openfhe.discourse.group/t/ram-consumption-of-ckks/2100 "2025-07-17T11:06:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![srovira](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@srovira](https://openfhe.discourse.group/u/srovira)\
**Post date:** [July 17, 2025, 11:06am UTC](https://openfhe.discourse.group/t/ram-consumption-of-ckks/2100/1 "2025-07-17T11:06:47Z")

</div>

Hello! I’m trying to understand how to compute the RAM consumption of an application that uses OpenFHE CKKS implementation.

In particular, I want to know the requiered RAM (in MB) of the following:

- Public/secret keys
- Keyswitching keys
- Automorphism keys
- Fresh ciphertext

My first idea was to just use theoretical estimates to get those values but I would rather have more accurate numbers than relying on estimates.

My second approach has been to run the code in simple-real-numbers-serial.cpp and take the sizes of the generated files. However I do not know how well these values actually represent the real RAM consumption. After using htop I don’t think they are that far but I want to verify that somehow.

Any help on this would be much appreciated.

TLDR: Any thoughts on how to obtain precise RAM requirements for a given application in CKKS without using estimates?

---

<div class="post-metadata">

**Author:** ![ypolyakov](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/ypolyakov/32/47_2.png) [@ypolyakov](https://openfhe.discourse.group/u/ypolyakov)\
**Post date:** [July 19, 2025, 5:43pm UTC](https://openfhe.discourse.group/t/ram-consumption-of-ckks/2100/2 "2025-07-19T17:43:59Z")

</div>

Theoretical estimates are typically quite accurate (almost exact). This is what I use in most of the cases for the single-threaded execution. In multithreaded cases, the RAM consumption is typically higher.

The use of the size of serialized ciphertexts/keys is good when computing the communication requirements. There are some differences between the binary-serialized objects and RAM utilization (although they are typically within a factor of 2 from each other).

The theoretical estimation is more precise as you can exactly compute the RAM needed for individual polynomials and keys.

---

<div class="post-metadata">

**Author:** ![srovira](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@srovira](https://openfhe.discourse.group/u/srovira)\
**Post date:** [July 28, 2025, 2:29pm UTC](https://openfhe.discourse.group/t/ram-consumption-of-ckks/2100/3 "2025-07-28T14:29:34Z")

</div>

Thank you for your advice Yuriy.

Regarding the theoretical estimates, I’m using N\log\_2(Q\_L) / 4 bytes for public keys and fresh ciphertext and N d\_\text{num} \log\_2(Q\_L P) / 4 bytes for key switching keys and automorphishm keys (I’m assume I use hybrid key-switching). Do you recommend these estimates or do you know of some more fine-grained ones that fit better the RNS implementation of CKKS in OpenFHE?

---

<div class="post-metadata">

**Author:** ![ypolyakov](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/ypolyakov/32/47_2.png) [@ypolyakov](https://openfhe.discourse.group/u/ypolyakov)\
**Post date:** [July 30, 2025, 1:14pm UTC](https://openfhe.discourse.group/t/ram-consumption-of-ckks/2100/4 "2025-07-30T13:14:12Z")

</div>

I use more refined (RNS-based) estimates, i.e., 2 \times 64 N k / 8 = 16 N k for the public key and 2 \times 64 N d\_{num} (k + k’) /8 = 16 N d\_{num} (k + k’). Here, k is the number of RNS limbs in Q and k’ the number of RNS limbs in P.

---

<div class="post-metadata">

**Author:** ![srovira](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@srovira](https://openfhe.discourse.group/u/srovira)\
**Post date:** [July 31, 2025, 1:19pm UTC](https://openfhe.discourse.group/t/ram-consumption-of-ckks/2100/5 "2025-07-31T13:19:30Z")

</div>

Thank you for your reply Yuriy!
