RAM consumption for CKKS Bootstrapping KeyGen

Hi everyone,

I am using OpenFHE via Python and trying to approximate the RAM consumption during EvalBootstrapKeyGen(). The cryptocontext I am using is CKKS. Memory usage is the most critical factor for my current project, as I need to maintain a very high level of precision. My specific configuration is quite heavy due to these precision constraints:
multdepth = 29 (due to high-degree Chebyshev approximations).

SecurityLevel = HEStd_128_classic which forces RingDimension = 2^17

numSlots = int(RingDimension/2)

level_budget = [3,3] and bsgs_dim = [0,0].

Could you please let me know if there is any related work, benchmark or recommended way to measure or calculate the RAM for this exact setup?

Thank you so much for your help!

Please see Measuring size of bootstrapping keys The high level idea is that the bootstrapping key is composed of a number of identically-sized EvalAutomorphism (rotation) keys. You can serialize one of them, check its size, and then multiply this size by the number of keys. The size of each rotation key on disk is close to the size of each rotation key in memory.

In v1.6.0, we will expose special API for serializing bootstrapping keys (see Add API for serializing bootstrapping keys · Issue #353 · openfheorg/openfhe-development · GitHub)

One can also exactly compute the size of each rotation key in memory if the parameters are known, but this requires deep understanding of the underlying crypto parameters. Table 5 of Revisiting Homomorphic Encryption Schemes for Finite Fields can be used to compute the size of a rotation key for a given set of crypto parameters.

You can also use the classical Linux command to show peak RAM usage of EvalBoostrapKeyGen: /usr/bin/time -v

Thank you for the helpful response! However, I am stuck on determining the exact number of EvalAutomorphism (rotation) keys generated for my specific configuration. Is there a specific OpenFHE Python function I can call after EvalBootstrapKeyGen() to get the total number of rotation keys generated? Or is there a formula based on my parameters to calculate this number?

The closest function in OpenFHE 1.5.1 is SerializeEvalAutomorphismKey. You can serialize the keys and look at the size of the serialized file (all rotation keys are stored together). Make sure that you only use EvalBootstrapKeyGen in this experiment, i.e., no other rotation keys are created via EvalRotateKeyGen, EvalAtIndex, EvalSumKeyGen, etc. You can also serialize the EvalMult key, by running SerializeEvalMultKey - this will give you the size of one evaluation key. You can divide the size produced by SerializeEvalAutomorphismKey by the size of EvalMult key to get the total number of rotation keys.

In v1.6, we will expose a function that returns a vector (python list) of indices, i.e., we will provide a direct method.