Skip to content

Commit d866b1d

Browse files
aimen-djari64ix
authored andcommitted
Move encryption content from standalone guide to advanced section in run-iapp-without-ProtectedData
1 parent 4c045e6 commit d866b1d

File tree

5 files changed

+117
-183
lines changed

5 files changed

+117
-183
lines changed

src/guides/build-iapp/advanced/build-your-first-sgx-iapp.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,6 @@ to use some confidential data to get the full potential of the **Confidential
561561
Computing** paradigm. Check out next chapters to see how:
562562

563563
- [Access confidential assets from your iApp](access-confidential-assets.md)
564-
- [Protect the result](/guides/use-iapp/encrypt-and-decrypt-results.md)
565564

566565
<script setup>
567566
import { computed } from 'vue';

src/guides/build-iapp/outputs.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ Continue building with these guides:
141141

142142
- **[Inputs](/guides/build-iapp/inputs)** - Learn about the different input
143143
types available to your iApp
144-
- **[Encrypt results and decrypt them](/guides/use-iapp/encrypt-and-decrypt-results)** -
145-
End-to-end result protection and local decryption
146144
- **[App Access Control and Pricing](/guides/build-iapp/manage-access)** -
147145
Control who can use your iApp
148146
- **[Debugging Your iApp](/guides/build-iapp/debugging)** - Troubleshoot

src/guides/use-iapp/encrypt-and-decrypt-results.md

Lines changed: 0 additions & 178 deletions
This file was deleted.

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

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

src/references/iapp-generator.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ Once you've built your first iApp, level up with these practical guides:
4444
- **[Inputs](/guides/build-iapp/inputs)** - Handle data inputs
4545
- **[Outputs](/guides/build-iapp/outputs)** - Handle data outputs flow in TEE
4646
environment
47-
- **[Encrypt results and decrypt them](/guides/use-iapp/encrypt-and-decrypt-results)** -
48-
Enable end-to-end result encryption and local decryption
4947
- **[Debugging Your iApp](/guides/build-iapp/debugging)** - Troubleshoot
5048
execution issues
5149
- **[App Access Control and Pricing](/guides/build-iapp/manage-access)** -

0 commit comments

Comments
 (0)