Scaling factor for bootstrap matrices

Hi,

I am reading the function EvalBootstrapSetup for ckks, and I was wondering if scaleEnc and scaleDec is necessary for general homomorphic slots-coeff switching.

Thanks for your time!

If you only want to do the homomorphic transformation between the slots/coefficients encodings, you do not need to be concerned with K, which is the number of overflows in the sine approximation inside bootstrapping. The other parts are for precision reasons in the context of bootstrapping.

Thank you for your response.

I would like to confirm one point: in typical application-level computations that involve homomorphic encoding and decoding, should both scaleEnc and scaleDec be set to 1?

Additionally, I noticed that during the bootstrapping process, there is a multiplication by a constant called constantEvalMult. Is this constant not incorporated into scaleEnc because the resulting product would be too small and could cause precision issues?

Lastly, I’m planning to implement a bootstrapping procedure that begins with an S2C (Slot-to-Coefficient) operation. In this case, how should I appropriately handle scaleEnc and scaleDec for the preceding S2C step?

I would greatly appreciate any insights or suggestions. Thank you in advance!

  • It depends on the application-level, you might want to scale the matrices corresponding to the FFT/IFFT for homomorphic decoding and encoding. You have to look at what is precomputed as the matrices and whether they correspond to what you want in EvalLinearTransformPrecompute and EvalCoeffsToSlotsPrecompute, EvalSlotsToCoeffsPrecompute. For instance, the encoding-related matrix does not contain 1/N.
  • Yes. In general, you want to design your computations to minimize the multiplicative depth. However, you have to be careful to not run into precision issues because by combining everything in a single multiplication, you end up with a value that is too small/too large to represent.
  • On the top of my head, scaleEnc and scaleDec don’t necessarily need to be changed, but that depends on your plan of implementation. However, the order of the steps (Encoding, ModRaise, Decoding, Evaluation) changes, so you need to change the levels for plaintext encoding and potentially other things.

The high-level idea behind scaleEnc and scaleDec is to embed the multiplication by a double into the generation of precomputed linear maps. The motivation is to reduce the multiplicative depth consumed by the multiplication by a double. This embedding approach is used a couple of times in CKKS bootstrapping to avoid explicit multiplications wherever possible.

I understand! Thanks for your help!