Attach a secret to your app
In this tutorial, you will learn how to leverage an application developer secret by using the IEXEC_APP_DEVELOPER_SECRET
environment variable in your application code.
Before going any further, make sure you managed to Build your first application with Scone framework.
Prerequisites:
Docker 17.05 or higher on the daemon and client.
iExec SDK 8.0.0 or higher. Install the iExec SDK
Familiarity with the basic concepts of Intel® SGX and SCONE framework.
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 securely associate an application developer secret to the runtime of an application. This association is performed through the usage of environment variables which cannot leak outside of the enclave memory.
The app developer secret is only exposed to your app inside authorized enclaves and never leaves them.
Your secrets are transferred with the SDK from your machine to the SMS over a TLS channel.
Let's see how to do all of that!
Prepare your application
For demo purposes, we omitted some development best practices in these examples.
Make sure to check your field's best practices before going to production.
Let's develop an application designed to evaluate the function:
where the coefficients a, b, c and d are kept confidential using an application secret, and the input x is given as argument of the app.
Let's create a directory tree for this app in ~/iexec-projects/
.
Make sure your chain.json
content is correct.
Copy the following content in src/
.
As seen above, a single slot is dedicated to store the application developer secret. If you want to use multiple secrets, feel free to pack your secrets into a single one and unpack them when reading the IEXEC_APP_DEVELOPER_SECRET
environment variable from the application code.
Build a Confidential Computing application
Build the docker image
In this section, you will:
Build the native image of the application as described in Build your first application.
Create and execute the
sconify.sh
script to build the Scone TEE application as we saw in Build Scone app > Prepare your application.
Create the Dockerfile
For a Javascript application:
For a Python application:
Build the docker image.
Follow the steps described in Build Scone app > Build the TEE docker image.
Update the sconify.sh
script with the variables as follow:
Run the sconify.sh
script to build the Scone TEE application:
Push the image on Docker Hub
Test your app on iExec
At this stage, your application is ready to be tested on iExec with the following steps:
Deploy the TEE app on iExec
Push an application developer secret to the SMS
In this example, the app developer's secret must be strictly defined in the following format a;b;c;d
.
For example set your secret to 1;1;1;1
for coeficients a,b,c,d.
For Secret Management Service security reasons, the app secret cannot be updated. Use with caution.
Check the secret exists in the SMS
Run the TEE app
Next step?
Thanks to the explained confidential computing workflow, you now know how to use an app developer secret in a Confidential Computing application.
To go further, check out how to:
Last updated