Sending encrypted code

The folder that contains the code of your Secure Computation must be organized like this:

$ tree my_folder
my_folder
├── secret_module.py
└── run.py

If you don’t know how to structure your code, visit Write code.

Before sending your code to the enclave, you have to generate a symmetric key. The Cosmian client provides a function for that, but you can also use whatever suits your security needs.

from cosmian_secure_computation_client.crypto.helper import random_symkey
symmetric_key = random_symkey()

Then, upload your code folder, specifying its path. This folder should contains a run.py file. All the files of this folder, except the run.py, will be encrypted.

# send_code.py

from cosmian_secure_computation_client import CodeProviderAPI
from pathlib import Path

path = Path("my_folder")

code_provider = CodeProviderAPI(cosmian_token)

code_provider.upload(computation_uuid, symmetric_key, path)