How to determing the number of towers?

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

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:

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.

1 Like

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?

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.

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