Registration
All participants need to create an account on the Cosmian platform by visiting https://console.cosmian.com to create their accounts. Then all participants need to register on the computation according to the role given to them by the computation owner. Note: if a participant shares multiple roles, it should register for each role.
-
Go to My Computations page and copy the computation UUID.
-
Go to Cosmian Console Secret token page and copy your secret token.
-
Ask the Computation Owner for the three random words they generate when creating the computation. These three words are a pre-shared secret. They are only known by the computation’s participants. Cosmian will never ask for them.
Register as code provider¶
# register.py
from pathlib import Path
from cosmian_secure_computation_client import CryptoContext, Side, CodeProviderAPI
# replace with your computation uuid
computation_uuid = "xxxxxxxxxxxxxxxxxxxxxx"
# replace with your token in Cosmian's console
cp_secret_token = "yyyyyyyyyyyyyyyyyyyyyy"
# replace with the words given by the Computation Owner
words = "word1-word2-word3"
cp_crypto_ctx = CryptoContext(computation_uuid=computation_uuid, side=Side.CodeProvider, words=words)
# Serialize and save your CryptoContext if you want to use it later:
Path("cp_crypto_context.json").write_text(cp_crypto_ctx.to_json(), encoding="utf-8")
# To deserialize:
# cp_crypto_ctx = CryptoContext.from_json(Path("cp_crypto_context.json").read_text(encoding="utf-8"))
code_provider = CodeProviderAPI(token=cp_secret_token, ctx=cp_crypto_ctx)
code_provider.register(computation_uuid)
New CryptoContext
generates a random asymmetric key pair and a random symmetric key. You can use your own key generated with OpenSSL as an example:
from pathlib import Path
from cosmian_secure_computation_client import CryptoContext
# To generate a new Ed25519 private key with OpenSSL:
# $ openssl genpkey -algorithm ed25519 -out ed25519-priv.pem
# To generate a random symmetric key:
# $ openssl rand -out symkey.bin 32
crypto_ctx = CryptoContext.from_path(
computation_uuid="xxxxxxxxxxxxxxxxxxxxxx", # replace this
side=Side.CodeProvider, # replace with your role: CodeProvider, DataProvider or ResultConsumer
words="word1-word2-word3", # replace with the words given by the Computation Owner
private_key=Path("ed25519-priv.pem"),
password=None, # optional password of the PEM file
symmetric_key=Path("symkey.bin")
)
Register as data provider¶
# register.py
from pathlib import Path
from cosmian_secure_computation_client import CryptoContext, Side, DataProviderAPI
# replace with your computation uuid
computation_uuid = "xxxxxxxxxxxxxxxxxxxxxx"
# replace with your token in Cosmian's console
dp_secret_token = "yyyyyyyyyyyyyyyyyyyyyy"
# replace with the words given by the Computation Owner
words = "word1-word2-word3"
dp_crypto_ctx = CryptoContext(computation_uuid=computation_uuid, side=Side.DataProvider, words=words)
# Serialize and save your CryptoContext if you want to use it later:
Path("dp_crypto_context.json").write_text(dp_crypto_ctx.to_json(), encoding="utf-8")
# To deserialize:
# dp_crypto_ctx = CryptoContext.from_json(Path("dp_crypto_context.json").read_text(encoding="utf-8"))
data_provider = DataProviderAPI(token=dp_secret_token, ctx=dp_crypto_ctx)
data_provider.register(computation_uuid)
New CryptoContext
generates a random asymmetric key pair and a random symmetric key. You can use your own key generated with OpenSSL as an example:
from pathlib import Path
from cosmian_secure_computation_client import CryptoContext
# To generate a new Ed25519 private key with OpenSSL:
# $ openssl genpkey -algorithm ed25519 -out ed25519-priv.pem
# To generate a random symmetric key:
# $ openssl rand -out symkey.bin 32
crypto_ctx = CryptoContext.from_path(
computation_uuid="xxxxxxxxxxxxxxxxxxxxxx", # replace this
side=Side.CodeProvider, # replace with your role: CodeProvider, DataProvider or ResultConsumer
words="word1-word2-word3", # replace with the words given by the Computation Owner
private_key=Path("ed25519-priv.pem"),
password=None, # optional password of the PEM file
symmetric_key=Path("symkey.bin")
)
Register as result consumer¶
# register.py
from pathlib import Path
from cosmian_secure_computation_client import CryptoContext, Side, ResultConsumerProviderAPI
# replace with your computation uuid
computation_uuid = "xxxxxxxxxxxxxxxxxxxxxx"
# replace with your token in Cosmian's console
rc_secret_token = "yyyyyyyyyyyyyyyyyyyyyy"
# replace with the words given by the Computation Owner
words = "word1-word2-word3"
rc_crypto_ctx = CryptoContext(computation_uuid=computation_uuid, side=Side.ResultConsumer, words=words)
# Serialize and save your CryptoContext if you want to use it later:
Path("rc_crypto_context.json").write_text(rc_crypto_ctx.to_json(), encoding="utf-8")
# To deserialize:
# rc_crypto_ctx = CryptoContext.from_json(Path("rc_crypto_context.json").read_text(encoding="utf-8"))
result_consumer = ResultConsumerAPI(token=rc_secret_token, ctx=rc_crypto_ctx)
result_consumer.register(computation_uuid)
New CryptoContext
generates a random asymmetric key pair and a random symmetric key. You can use your own key generated with OpenSSL as an example:
from pathlib import Path
from cosmian_secure_computation_client import CryptoContext
# To generate a new Ed25519 private key with OpenSSL:
# $ openssl genpkey -algorithm ed25519 -out ed25519-priv.pem
# To generate a random symmetric key:
# $ openssl rand -out symkey.bin 32
crypto_ctx = CryptoContext.from_path(
computation_uuid="xxxxxxxxxxxxxxxxxxxxxx", # replace this
side=Side.CodeProvider, # replace with your role: CodeProvider, DataProvider or ResultConsumer
words="word1-word2-word3", # replace with the words given by the Computation Owner
private_key=Path("ed25519-priv.pem"),
password=None, # optional password of the PEM file
symmetric_key=Path("symkey.bin")
)