Use confidential assets
Prerequisites
Docker 17.05 or higher on the daemon and client.
Nodejs 14.0.0 or higher.
iExec SDK 7.2.0 or higher.
Familiarity with the basic concepts of Intel® SGX and SCONE framework.
Please make sure you have already checked the Quickstart, Your first application and Build trusted applications tutorials before learning how to manage confidential datasets.
Trusted Execution Environments offer a huge advantage from a security perspective. They guarantee that the behavior of execution does not change even when launched on an untrusted remote machine. The data inside this type of environment is also protected, which allows its monetization while preventing leakage.
With iExec, it is possible to authorize only applications you trust to use your datasets and get paid for it. Data is encrypted using standard encryption mechanisms and the plain version never leaves your machine. The encrypted version is made available for usage and the encryption key is pushed into the SMS. After you deploy the dataset on iExec it is you, and only you, who decides which application is allowed to get the secret to decrypt it.
Datasets are only decrypted inside authorized enclaves and never leave them. The same thing applies to secrets.
Your secrets are securely transferred with the SDK from your machine to the SMS over a TLS channel. Internally, your secrets are encrypted with standard AES encryption before being written to disk. Next releases will feature an SMS running entirely inside a trusted enclave.
Let's see how to do all of that!
Encrypt the dataset
Before starting, let's make sure we are inside the folder ~/iexec-projects
- created previously, during the quick start tutorial.
Init the dataset configuration.
This command will create the folders datasets/encrypted
, datasets/original
and .secrets/datasets
. A new section "dataset"
will be added to the iexec.json
file as well.
We will create a dummy file that has "Hello, world!"
as content inside datasets/original
. Alternatively, you can put your own dataset file.
Now run the following command to encrypt the file:
iexec dataset encrypt
will output a checksum, keep this value for a later use.
As you can see, the command generated the file datasets/encrypted/my-first-dataset.txt.enc
. That file is the encrypted version of your dataset, you should push it somewhere accessible because the worker will download it during the execution process. You will enter this file's URI in the iexec.json
file (multiaddr
attribute) when you will deploy your dataset. Make sure that the URI is a DIRECT download link (not a link to a web page for example).
You can use Github for example to publish the file but you should add /raw/ to the URI like this: https://github.com/<username>/<repo>/raw/master/my-first-dataset.zip
The file .secrets/datasets/my-first-dataset.txt.key
is the encryption key, make sure to back it up securely. The file .secrets/datasets/dataset.key
is just an "alias" in the sense that it is the key of the last encrypted dataset.
Deploy the dataset
Fill in the fields of the iexec.json
file. Choose a name
for your dataset, put the encrypted file's URI in multiaddr
(the URI you got after publishing the file), and add the checksum
(you can get it by running sha256sum datasets/encrypted/my-first-dataset.txt.enc
)
To deploy your dataset run:
You will get a hexadecimal address for your deployed dataset. Use that address to push the encryption key to the SMS so it is available for authorized applications.
For simplicity, we will use the dataset with a TEE-debug app on a debug workerpool. The debug workerpool is connected to a debug Secret Management Service so we will send the dataset encryption key to this SMS (this is fine for debugging but do not use to store production secrets).
These sed
commands will do the trick:
We saw in this section how to encrypt a dataset and deploy it on iExec. In addition, we learned how to push the encryption secret to the SMS. Now we need to build the application that is going to consume this dataset.
Prepare your application
Let's create a directory tree for this app in ~/iexec-projects/
.
In the folder src/
create the file app.js
or app.py
then copy this code inside:
The application reads the content of the dataset and writes it into the result's folder (in an artistic way using Figlet):
Build the TEE docker image
The Dockerfile and the build scripts are the same as the ones we saw previously for a trusted application:
Run the sconify.sh
script to build the TEE-debug app.
The sconify.sh
script prints the generated docker image name, you must retag this image and push it on dockerhub.
Test your app on iExec
At this stage, your application is ready to be tested on iExec. The process is similar to testing any type of application on the platform, with these minor exceptions:
Deploy the TEE app on iExec
TEE applications require some additional information to be filled in during deployment.
Edit iexec.json
and fill in the standard keys and the mrenclave
object:
Run your TEE image with SCONE_HASH=1
to get the enclave fingerprint (mrenclave):
Deploy the app with the standard command:
Run the TEE app
Specify the tag --tag tee
and the dataset to use --dataset <datasetAddress>
in iexec app run
command to run a tee app with a dataset.
One last thing, in order to run a TEE-debug app you will also need to select a debug workerpool, use the debug workerpool v7-debug.main.pools.iexec.eth
.
You are now ready to run the app
Next step?
Thanks to the explained confidential computing workflow, it is possible to use an encrypted dataset with a trusted application. We can go another step further and protect the result too. See in the next chapter how to make your execution result encrypted so that you are the only one who can read it.
Last updated