Skip to content

Commit 1a6e98c

Browse files
committed
Refactor iApp guide: move encryption details to a dedicated section and update navigation in sidebar
1 parent 1d17a7c commit 1a6e98c

File tree

2 files changed

+147
-135
lines changed

2 files changed

+147
-135
lines changed
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
---
2+
title: Encrypt iApp Results
3+
description:
4+
Learn how to encrypt iApp execution results using end-to-end encryption with
5+
your own encryption key pair
6+
---
7+
8+
# 🔐 Encrypt iApp Results
9+
10+
::: info
11+
12+
If you're using DataProtector, result encryption is handled automatically within
13+
the processProtectedData method, with the associated parameter. This section is
14+
only needed for manual encryption when not using DataProtector.
15+
16+
:::
17+
18+
Secure your outputs with end‑to‑end encryption so only you (the beneficiary) can
19+
read them. Results leave the enclave and may traverse untrusted storage and
20+
networks; encryption ensures nobody else (operators, storage providers,
21+
intermediaries) can access the content.
22+
23+
## 1) Generate your encryption key pair
24+
25+
The beneficiary key pair is the root of trust for result confidentiality. The
26+
public key will be used inside the TEE to encrypt results for the beneficiary;
27+
the private key stays with the beneficiary to decrypt them locally.
28+
29+
Run from your iExec project directory:
30+
31+
```bash
32+
iexec result generate-encryption-keypair
33+
```
34+
35+
This creates two files in `.secrets/beneficiary/`:
36+
37+
```
38+
.secrets/
39+
└─ beneficiary/
40+
├─ <0x-your-wallet-address>_key # PRIVATE KEY (keep safe)
41+
└─ <0x-your-wallet-address>_key.pub # PUBLIC KEY
42+
```
43+
44+
Back up the private key securely. You will only need it locally to decrypt
45+
results.
46+
47+
## 2) Push your public key to the SMS
48+
49+
The Secret Management Service securely delivers your public key, at runtime, to
50+
the enclave running your iApp. Without this, the iApp cannot encrypt outputs for
51+
you.
52+
53+
Make the public key available to TEEs at runtime:
54+
55+
```bash
56+
iexec result push-encryption-key --tee-framework scone
57+
```
58+
59+
Verify it:
60+
61+
```bash
62+
iexec result check-encryption-key --tee-framework scone
63+
```
64+
65+
## 3) Run the iApp with encrypted results
66+
67+
The --encrypt-result flag instructs the platform to perform envelope encryption
68+
inside the enclave using your public key, so the archive that leaves the TEE is
69+
unreadable to others.
70+
71+
Trigger a task and request encrypted outputs:
72+
73+
```bash
74+
iexec app run <0x-app-address> \
75+
--workerpool <0x-workerpool-address> \
76+
--tag tee,scone \
77+
--encrypt-result \
78+
--watch
79+
```
80+
81+
When completed, download the results archive:
82+
83+
```bash
84+
iexec task show <0x-task-id> --download
85+
```
86+
87+
Inside the archive, `iexec_out/result.zip.aes` is encrypted.
88+
89+
Note: Results are encrypted for the task beneficiary. Ensure the beneficiary
90+
address is yours to be able to decrypt the archive.
91+
92+
If you extract the archive and try to read the encrypted file, you'll see
93+
unreadable content:
94+
95+
```bash
96+
mkdir /tmp/trash && \
97+
unzip <0x-your-task-id>.zip -d /tmp/trash && \
98+
cat /tmp/trash/iexec_out/result.zip.aes
99+
```
100+
101+
The output will look like:
102+
103+
```bash
104+
)3XqYvzEfRu<mm疞rc(a{{'ܼ͛q/[{hgD$g\.kj"s?"hJ_Q41_[{XԚa蘟vEr肽
105+
Յ]9WTL*tdzO`!e&snoL3K6L9%
106+
```
107+
108+
This confirms the results are properly encrypted and unreadable without the
109+
private key.
110+
111+
## 4) Decrypt results locally
112+
113+
Results are encrypted end‑to‑end; only your private key can decrypt them. This
114+
step restores the plaintext so you can use the output files.
115+
116+
Use your private key generated in step 1:
117+
118+
```bash
119+
iexec result decrypt iexec_out/result.zip.aes
120+
```
121+
122+
This produces `results.zip`. Extract it to view plaintext outputs:
123+
124+
```bash
125+
unzip results.zip -d my-decrypted-result
126+
```
127+
128+
And you can see the content of your result file:
129+
130+
```bash
131+
$ cat my-decrypted-result/result.txt
132+
Hello, world!
133+
```
134+
135+
Your results are now decrypted and ready to use.
136+
137+
## Notes and tips
138+
139+
- Keep the private key offline and backed up.
140+
- You can rotate keys by re-running generation and push steps; old tasks remain
141+
decryptable with the old private key.
142+
- iApp code does not need changes to enable result encryption; it is enforced by
143+
the TEE using the public key from SMS.

src/guides/use-iapp/run-iapp-without-ProtectedData.md

Lines changed: 4 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -201,139 +201,8 @@ const taskId = await iexec.order.matchOrders({
201201
});
202202
```
203203

204-
## 🔐 Encrypt Results (Advanced)
204+
## Next Steps
205205

206-
::: info
207-
208-
DataProtector handles encryption automatically If you're using DataProtector,
209-
result encryption is handled automatically. This section is only needed for
210-
manual encryption when not using DataProtector.
211-
212-
:::
213-
214-
Secure your outputs with end‑to‑end encryption so only you (the beneficiary) can
215-
read them. Results leave the enclave and may traverse untrusted storage and
216-
networks; encryption ensures nobody else (operators, storage providers,
217-
intermediaries) can access the content.
218-
219-
### 1) Generate your encryption key pair
220-
221-
The beneficiary key pair is the root of trust for result confidentiality. The
222-
public key will be used inside the TEE to encrypt results for the beneficiary;
223-
the private key stays with the beneficiary to decrypt them locally.
224-
225-
Run from your iExec project directory:
226-
227-
```bash
228-
iexec result generate-encryption-keypair
229-
```
230-
231-
This creates two files in `.secrets/beneficiary/`:
232-
233-
```
234-
.secrets/
235-
└─ beneficiary/
236-
├─ <0x-your-wallet-address>_key # PRIVATE KEY (keep safe)
237-
└─ <0x-your-wallet-address>_key.pub # PUBLIC KEY
238-
```
239-
240-
Back up the private key securely. You will only need it locally to decrypt
241-
results.
242-
243-
### 2) Push your public key to the SMS
244-
245-
The Secret Management Service securely delivers your public key, at runtime, to
246-
the enclave running your iApp. Without this, the iApp cannot encrypt outputs for
247-
you.
248-
249-
Make the public key available to TEEs at runtime:
250-
251-
```bash
252-
iexec result push-encryption-key --tee-framework scone
253-
```
254-
255-
Verify it:
256-
257-
```bash
258-
iexec result check-encryption-key --tee-framework scone
259-
```
260-
261-
### 3) Run the iApp with encrypted results
262-
263-
The --encrypt-result flag instructs the platform to perform envelope encryption
264-
inside the enclave using your public key, so the archive that leaves the TEE is
265-
unreadable to others.
266-
267-
Trigger a task and request encrypted outputs:
268-
269-
```bash
270-
iexec app run <0x-app-address> \
271-
--workerpool <0x-workerpool-address> \
272-
--tag tee,scone \
273-
--encrypt-result \
274-
--watch
275-
```
276-
277-
When completed, download the results archive:
278-
279-
```bash
280-
iexec task show <0x-task-id> --download
281-
```
282-
283-
Inside the archive, `iexec_out/result.zip.aes` is encrypted.
284-
285-
Note: Results are encrypted for the task beneficiary. Ensure the beneficiary
286-
address is yours to be able to decrypt the archive.
287-
288-
If you extract the archive and try to read the encrypted file, you'll see
289-
unreadable content:
290-
291-
```bash
292-
mkdir /tmp/trash && \
293-
unzip <0x-your-task-id>.zip -d /tmp/trash && \
294-
cat /tmp/trash/iexec_out/result.zip.aes
295-
```
296-
297-
The output will look like:
298-
299-
```bash
300-
)3XqYvzEfRu<mm疞rc(a{{'ܼ͛q/[{hgD$g\.kj"s?"hJ_Q41_[{XԚa蘟vEr肽
301-
Յ]9WTL*tdzO`!e&snoL3K6L9%
302-
```
303-
304-
This confirms the results are properly encrypted and unreadable without the
305-
private key.
306-
307-
### 4) Decrypt results locally
308-
309-
Results are encrypted end‑to‑end; only your private key can decrypt them. This
310-
step restores the plaintext so you can use the output files.
311-
312-
Use your private key generated in step 1:
313-
314-
```bash
315-
iexec result decrypt iexec_out/result.zip.aes
316-
```
317-
318-
This produces `results.zip`. Extract it to view plaintext outputs:
319-
320-
```bash
321-
unzip results.zip -d my-decrypted-result
322-
```
323-
324-
And you can see the content of your result file:
325-
326-
```bash
327-
$ cat my-decrypted-result/result.txt
328-
Hello, world!
329-
```
330-
331-
Your results are now decrypted and ready to use.
332-
333-
### Notes and tips
334-
335-
- Keep the private key offline and backed up.
336-
- You can rotate keys by re-running generation and push steps; old tasks remain
337-
decryptable with the old private key.
338-
- iApp code does not need changes to enable result encryption; it is enforced by
339-
the TEE using the public key from SMS.
206+
For advanced use cases where you need to encrypt the results of your iApp
207+
execution, refer to the [Encrypt iApp Results](/guides/use-iapp/encrypt-result)
208+
guide.

0 commit comments

Comments
 (0)