# KeySwitch key serialization

**URL:** <https://openfhe.discourse.group/t/keyswitch-key-serialization/579>\
**Category:** Library Questions\
**Created:** [May 24, 2023, 7:03am UTC](https://openfhe.discourse.group/t/keyswitch-key-serialization/579 "2023-05-24T07:03:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nightingale](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/nightingale/32/93_2.png) [@Nightingale](https://openfhe.discourse.group/u/Nightingale)\
**Post date:** [May 24, 2023, 7:03am UTC](https://openfhe.discourse.group/t/keyswitch-key-serialization/579/1 "2023-05-24T07:03:33Z")

</div>

Hi,  
I want to send keyswitch key to any party, i try to use serialization but i have a mistake :

` Exception: /usr/local/include/openfhe/pke/cryptoobject.h:116 serialized object version 1073741824 is from a later version of the library`

my serialization code (I can’t find any specific serialization code for keyswitching key):

```auto
Serial::Serialize(ek, os, SerType::BINARY);
Serial::Deserialize(ek, is, SerType::BINARY);

```

How can i solve it?

---

<div class="post-metadata">

**Author:** ![ypolyakov](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/ypolyakov/32/47_2.png) [@ypolyakov](https://openfhe.discourse.group/u/ypolyakov)\
**Post date:** [May 26, 2023, 6:49pm UTC](https://openfhe.discourse.group/t/keyswitch-key-serialization/579/2 "2023-05-26T18:49:04Z")

</div>

Could you provide more information, including the code example(s) to recreate the issue and the environment you are using? Are you using a different machine for deserialization? If yes, are the same versions of OpenFHE installed on both machines?

If you run `Deserialize` on the same machine, I suggest running all unit tests (there are some that test serialization for evaluation keys). Do all tests pass?

---

<div class="post-metadata">

**Author:** ![Nightingale](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/nightingale/32/93_2.png) [@Nightingale](https://openfhe.discourse.group/u/Nightingale)\
**Post date:** [May 27, 2023, 4:04pm UTC](https://openfhe.discourse.group/t/keyswitch-key-serialization/579/3 "2023-05-27T16:04:18Z")

</div>

I am using Linux system on WSL.  
I want to implement multi party system so ı have to perform distributed protocol and my system required partialy evaluation key. to generate multiSwitchKeyGen function i need the key of the previous party, but i cant send it. I am trying on the same machine (at localhost).

I use following specific serialization function for evalmultkey and automorphismkey and they are working true. Also ı am using Reencryption key and i can send with `Serialize,Deserialize` functions. Since i dont see any specific function for sending keyswitching key, i tried Serialize,Deserialize` functions, but it is not working, i have above mistake.

```auto
SerializeEvalMultKey
SerializeEvalAutomorphismKey

```

thank you for your suggestion, i will run.

---

<div class="post-metadata">

**Author:** ![ypolyakov](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/ypolyakov/32/47_2.png) [@ypolyakov](https://openfhe.discourse.group/u/ypolyakov)\
**Post date:** [June 2, 2023, 4:03am UTC](https://openfhe.discourse.group/t/keyswitch-key-serialization/579/4 "2023-06-02T04:03:33Z")

</div>

I suggest reading this thread: [What's the best way to use openFHE on two sides?](https://openfhe.discourse.group/t/whats-the-best-way-to-use-openfhe-on-two-sides/380). It should contain answers to your questions.
