Skip to content

Run the computation

Run the computation

The Secure Computations will automatically run when all the participants have provided their sealed keys.

As a Result Consumer, you have created a symmetric key, sealed it with the enclave’s public key and sent it to the enclave.

from pathlib import Path

from cosmian_secure_computation_client import ResultConsumerAPI, CryptoContext

# load the previous CryptoContext created at the registration step
rc_crypto_ctx = CryptoContext.from_json(Path("rc_crypto_ctx.json").read_text(encoding="utf-8"))
result_consumer = ResultConsumerAPI(cosmian_token, rc_crypto_ctx)
computation_uuid = "xxxxxxxxxxxxxxxxxxxxxx"

enclave_public_key: bytes = result_consumer.wait_for_enclave_identity(computation_uuid)

computation = result_consumer.get_computation(computation_uuid)
manifest = computation.enclave.identity.manifest
quote = computation.enclave.identity.quote

result_consumer.key_provisioning(computation.uuid, enclave_public_key)

Then just use a blocking wait to get the result:

result: bytes = result_consumer.wait_result(computation_uuid)
# do whatever you want with the result...

Please note that results are represented in bytes, the code provider is the one who knows what is the representation of the output. It could be bytes of a CSV file, NumPy datastructure, object pickled, protobuf message, JSON encoded as UTF-8 and so on.

© Copyright 2018-2022 Cosmian. All rights reserved