# CKKS Rotation Key Memory Size

**URL:** <https://openfhe.discourse.group/t/ckks-rotation-key-memory-size/1407>\
**Category:** Library Questions\
**Created:** [July 5, 2024, 2:12pm UTC](https://openfhe.discourse.group/t/ckks-rotation-key-memory-size/1407 "2024-07-05T14:12:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sumw](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@sumw](https://openfhe.discourse.group/u/sumw)\
**Post date:** [July 5, 2024, 2:12pm UTC](https://openfhe.discourse.group/t/ckks-rotation-key-memory-size/1407/1 "2024-07-05T14:12:12Z")

</div>

For my application, I need to do `log(GetRingDimension()/2)` to perform algebraic operations that require iterating through every single slot in my ciphertext.  
However, when I try to generate the rotation keys, my program will get killed, which I suspect is a memory issue.  
Following are the parameters I am trying to use:

```auto
usint depth = levelsAvailableAfterBootstrap + FHECKKSRNS::GetBootstrapDepth(levelBudget, secretKeyDist);
using levelsAvailableAfterBootstrap = 14;
std::vector<uint32_t> levelBudget = {3, 3};
    uint32_t approxBootstrapDepth = 9;
    std::vector<uint32_t> bsgsDim = {0, 0};
usint firstMod = 60;
parameters.SetKeySwitchTechnique(HYBRID);
parameters.SetScalingTechnique(rescaleTech);
usint ScaleModSize = 50;

```

I will get 131072 from `GetRingDimension()` after setting all the parameters. Is there a way to estimate my rotation key memory size and reduce the memory size of them?

---

<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 5, 2024, 8:43pm UTC](https://openfhe.discourse.group/t/ckks-rotation-key-memory-size/1407/2 "2024-07-05T20:43:45Z")

</div>

Please read [Bootstrapping AutomorphismKey keys exceeds maximum protobuf size of 2GB](https://openfhe.discourse.group/t/bootstrapping-automorphismkey-keys-exceeds-maximum-protobuf-size-of-2gb/505). You may also find [Size of Rotation keys](https://openfhe.discourse.group/t/size-of-rotation-keys/484) useful.
