# How to determing the number of towers?

**URL:** <https://openfhe.discourse.group/t/how-to-determing-the-number-of-towers/388>\
**Category:** FHE Questions\
**Tags:** questions\
**Created:** [February 27, 2023, 11:58am UTC](https://openfhe.discourse.group/t/how-to-determing-the-number-of-towers/388 "2023-02-27T11:58:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lance](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@lance](https://openfhe.discourse.group/u/lance)\
**Post date:** [February 27, 2023, 11:58am UTC](https://openfhe.discourse.group/t/how-to-determing-the-number-of-towers/388/1 "2023-02-27T11:58:19Z")

</div>

As the title, how to determine the number of tower? which is the parameter `numTower` in OpenFHE.

---

<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 27, 2023, 3:16pm UTC](https://openfhe.discourse.group/t/how-to-determing-the-number-of-towers/388/2 "2023-02-27T15:16:16Z")

</div>

Once the crypto context is initialized, encrypt a plaintext to generate a ciphertext, say `ctxt`. Then you can print out the number of towers in the primary ciphertext coefficient modulus (Q) as follows:

```auto
std::vector<double> x = {0.25, 0.75, 2.0, 4.0};
Plaintext ptxt = cryptoContext->MakeCKKSPackedPlaintext(x);
auto ctxt= cryptoContext->Encrypt(keyPair.publicKey, ptxt);
std::cout << "numTowers: " << ctxt->GetElements()[0].GetAllElements().size() << std::endl;

```

Note that, OpenFHE uses “extra” auxiliary towers - as part of auxiliary RNS modulus P - which are only used in some intermediate computations. The commands above do not show those extra towers.

---

<div class="post-metadata">

**Author:** ![malioboro](https://avatars.discourse-cdn.com/v4/letter/m/eb8c5e/32.png) [@malioboro](https://openfhe.discourse.group/u/malioboro)\
**Post date:** [October 21, 2024, 8:07pm UTC](https://openfhe.discourse.group/t/how-to-determing-the-number-of-towers/388/3 "2024-10-21T20:07:25Z")

</div>

I set multiplicativeDepth = 1 but when I printed I got the number of towers = 3. I am not sure, I thought the number of towers would be the same with the multiplicativeDepth, are these extra towers the auxiliary towers you mean? or my understanding that number of towers is equal to number of multiplicativeDepth is incorrect?

---

<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:** [October 21, 2024, 8:39pm UTC](https://openfhe.discourse.group/t/how-to-determing-the-number-of-towers/388/4 "2024-10-21T20:39:12Z")

</div>

Number of towers in CKKS (for a fresh ciphertext with maximum number of levels) = the multiplicative depth + 1 (for decryption in FIXED\* and FLEXIBLEAUTO modes) or + 2 (for FLEXIBLEAUTOEXT mode). One tower is always needed for decryption. Another tower is used by FLEXIBLEAUTOEXT to achieve higher CKKS precision.

---

<div class="post-metadata">

**Author:** ![malioboro](https://avatars.discourse-cdn.com/v4/letter/m/eb8c5e/32.png) [@malioboro](https://openfhe.discourse.group/u/malioboro)\
**Post date:** [October 21, 2024, 8:43pm UTC](https://openfhe.discourse.group/t/how-to-determing-the-number-of-towers/388/5 "2024-10-21T20:43:49Z")

</div>

I see… I just learned about FLEXIBLEAUTO and FLEXIBLEAUTOEXT today, thank you!
