Encrypting communication between 2 RPIs

I have scattered your forums trying to look for an answer but after having read through Same Encryption key for 2 Zymkeys I was not able to find an answer.

In essence, what Im trying to do is to set up a client-server communication method where a message that is sent from a client RPI is first encrypted and decrypted when it arrives at the server RPI. Is this at all possible considering that the RPIs have two different ZymKeys installed?

This is a rough sketch of my scripts so far, I hope it gives more insight into what Im trying to do.
Client-side-script:
client

Server-side-script:
server

When I run these scripts I get the following error:

I am very new to this so any advice would be greatly appreciated. Sorry if my question doesnt make sense:)

Any suggestions? :slight_smile: I havent found a way to make this work yet.

@Mr123 This is not possible with a Zymkey. The private keys are unique to each Zymkey. You can only lock/unlock data blobs on the particular Zymkey itself. You would have to leave your data locked until returning to the first Zymkey to unlock.

So there is no work-around or different way to write these scripts to make communication possible using a ZymKey? Can I not generate a key pair between the client and server and have it so the client encrypts the data using the server’s public key, and then the server decrypts the data using its private key?