# How to serialize the SchemeSwitching keys

**URL:** <https://openfhe.discourse.group/t/how-to-serialize-the-schemeswitching-keys/1031>\
**Category:** FHE Questions\
**Tags:** questions\
**Created:** [January 19, 2024, 10:17am UTC](https://openfhe.discourse.group/t/how-to-serialize-the-schemeswitching-keys/1031 "2024-01-19T10:17:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cesare](https://avatars.discourse-cdn.com/v4/letter/c/dfb087/32.png) [@Cesare](https://openfhe.discourse.group/u/Cesare)\
**Post date:** [January 19, 2024, 10:17am UTC](https://openfhe.discourse.group/t/how-to-serialize-the-schemeswitching-keys/1031/1 "2024-01-19T10:17:09Z")

</div>

Hi all,  
I wanted to use schemeswitching to outsource the comparison. But I do not how to serialize the keys about schemeswitching. Because the bootstrapping keys are serialized as evalmult keys and rotation keys， I think the schemeswitching may be as evalkeys. I serialize the context and keys(only CKKS and FHEW), but the comparison do not work after reading the context and keys.

I want to know how to serialize the schemeswitching keys and extra information. Thanks for your help.

The error occurs in the slotsToCoeffs. The error is

```auto
ckksrns/ckksrns-schemeswitching.cpp:1041 Precomputations for 0 slots were not generated Need to call EvalCKKSToFHEWPrecompute to proceed
Aborted

```

I do not understand the slots is 0.

---

<div class="post-metadata">

**Author:** ![andreea.alexandru](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/andreea.alexandru/32/378_2.png) [@andreea.alexandru](https://openfhe.discourse.group/u/andreea.alexandru)\
**Post date:** [January 19, 2024, 3:52pm UTC](https://openfhe.discourse.group/t/how-to-serialize-the-schemeswitching-keys/1031/2 "2024-01-19T15:52:03Z")

</div>

Hi Cesare, the scheme switching serialization is quite complicated because of the different cryptocontexts and keys that are needed. The error you see signals that deserialization is not performed correctly in your code (the slots is not set, so it defaults to the value 0).

The full serialization functionality is currently in the dev branch, not in main. It will be merged in the next version. But you can check [openfhe-development/src/pke/examples/scheme-switching-serial.cpp at dev · openfheorg/openfhe-development · GitHub](https://github.com/openfheorg/openfhe-development/blob/dev/src/pke/examples/scheme-switching-serial.cpp) to see an example of the scheme switching serialization.

---

<div class="post-metadata">

**Author:** ![Cesare](https://avatars.discourse-cdn.com/v4/letter/c/dfb087/32.png) [@Cesare](https://openfhe.discourse.group/u/Cesare)\
**Post date:** [January 22, 2024, 1:25am UTC](https://openfhe.discourse.group/t/how-to-serialize-the-schemeswitching-keys/1031/3 "2024-01-22T01:25:46Z")

</div>

Thanks for you reply.  
I’m reading the source code and the papers right now, because I am not familiar to chimera and pegasus.  
Looking forward to the relevant features being added.
