Skip to content

Creating a computation

Create a new computation as a Computation Owner by providing a computation name, the list of participants and your secret token.

Get your secret token

Go to Cosmian Console Secret token page and copy your secret token. Store your token inside an env variable.

Some browser’s extension may interfere with the token page

Some browser’s extension, like Privacy Badger, may interfere with the token page. These extension should be deactivate for the domain for the token generation to work properly.

Also, if you use Google Chrome, you should allow third-party cookies for now. We are working toward a fix to this issue.

Install the librairies

Install cosmian_secure_computation_client library.

pip install cosmian_secure_computation_client

Create a python file and import cosmian_secure_computation_client. You will also need python subprocess.


from cosmian_secure_computation_client import Computation, ComputationOwnerAPI, CodeProviderAPI, DataProviderAPI, ResultConsumerAPI
import subprocess


Create your PGP public key

Create your public key using subprocess library and gpg.

my_name = "John Doe"
my_email = ""

subprocess.Popen(['gpg', '--batch', '--passphrase', '', '--quick-generate-key', f'{my_name} <{my_email}>', 'ed25519', 'cert', 'never'], stdout=subprocess.PIPE,  stderr=subprocess.PIPE, universal_newlines=True).communicate()
public_key, stderr = subprocess.Popen(['gpg', '--export', '--armor', my_email], stdout=subprocess.PIPE,  stderr=subprocess.PIPE, universal_newlines=True).communicate()

Initialize the computation

Specify the computation name, your pgp public key and email addresses of the different participants: only one code provider bute several data providers and several result consumers are accepted. You will be the Computation Owner of this computation.

computation_name = "My first computation"
cosmian_token = environ.get('COSMIAN_TOKEN')
computation_owner = ComputationOwnerAPI(cosmian_token)

computation = computation_owner.create_computation(
    data_providers_emails=["", ""],
    result_consumers_emails=["", ""]

Congratulations! Your first computation is created and ready to receive encrypted code and encrypted data. Visit My Computations page to see the list of your computations. Other participants will also see this computation on their page.


Cosmian automatically archives computations after seven (7) days. You cannot interact or download the result of an archived computation, but you can still fetch the computation’s checklist.