Hi,
I am implementing a pipeline where a ciphertext is generated externally, reconstructed in OpenFHE by manually setting its polynomial elements and metadata, KeySwitched to a server key, multiplied twice by a scalar, and then scheme-switched to FHEW via EvalCKKStoFHEW.
The scheme switch throws a modulus mismatch error inside EvalSlotsToCoeffsSwitch: terminate called after throwing an instance of ‘lbcrypto::OpenFHEException’ what(): /usr/local/include/openfhe/core/lattice/hal/default/poly.h:l.274:operator*=(): Modulus mismatch Aborted (core dumped)
What I verified:
-
Decryption works correctly at every step of the pipeline
-
The failing ciphertext has identical metadata to a working one: level=2, nprimes=5, nsd=1, slots=4, scale=2^28, encodingType=CKKS_PACKED_ENCODING
-
The DCRTPoly params pointer is the same object as in a normally encrypted ciphertext
-
The exact same pipeline (KeySwitch → multiply → scheme switch) works perfectly when the initial ciphertext is encrypted by OpenFHE instead of reconstructed from external bytes
I suspect there is an internal state or property that OpenFHE sets during normal encryption that is not captured by the public setter methods, and thatEvalSlotsToCoeffsSwitchrelies on this internally. Could you point me to what is missing when reconstructing a ciphertext from external coefficients, and how I can correctly initialize it to makeEvalCKKStoFHEWwork in this scenario?