|
1 | 1 | --- |
2 | | -title: Inputs and Outputs |
| 2 | +title: Inputs |
3 | 3 | description: |
4 | | - Understand the different input types and output formats for iApp in the TEE |
| 4 | + Understand the different input types available to your iApp in the TEE |
5 | 5 | environment |
6 | 6 | --- |
7 | 7 |
|
8 | | -# 📥📤 Inputs and Outputs |
| 8 | +# 📥 Inputs |
9 | 9 |
|
10 | 10 | **Your iApp runs inside a secure TEE environment with access to different types |
11 | 11 | of inputs.** Understanding what data you can access, how to access it, and when |
12 | 12 | to use each type is crucial for building effective privacy-preserving |
13 | 13 | applications. |
14 | 14 |
|
15 | | -This guide covers all input types available to your iApp and how to generate |
16 | | -proper outputs that users can retrieve and decrypt. |
| 15 | +This guide covers all input types available to your iApp and how to access them |
| 16 | +within the TEE environment. |
17 | 17 |
|
18 | 18 | ## Two perspectives on inputs |
19 | 19 |
|
@@ -356,124 +356,6 @@ const processProtectedDataResponse = |
356 | 356 | }); |
357 | 357 | ``` |
358 | 358 |
|
359 | | -## Creating Outputs |
360 | | - |
361 | | -Your iApp must generate outputs in the `IEXEC_OUT` directory. **Every iApp must |
362 | | -create a `computed.json` file** with metadata about the computation. |
363 | | - |
364 | | -### Basic Output Structure |
365 | | - |
366 | | -::: code-group |
367 | | - |
368 | | -```python [Python] |
369 | | -import os |
370 | | -import json |
371 | | - |
372 | | -# Get output directory |
373 | | -iexec_out = os.environ['IEXEC_OUT'] |
374 | | - |
375 | | -# Create your result file |
376 | | -result_data = { |
377 | | - "analysis": "positive sentiment", |
378 | | - "confidence": 0.92, |
379 | | - "processed_at": "2024-01-15T10:30:00Z" |
380 | | -} |
381 | | - |
382 | | -# Save main result |
383 | | -with open(f"{iexec_out}/result.json", 'w') as f: |
384 | | - json.dump(result_data, f) |
385 | | - |
386 | | -# REQUIRED: Create `computed.json` metadata |
387 | | -computed_metadata = { |
388 | | - "deterministic-output-path": f"{iexec_out}/result.json", |
389 | | - "execution-timestamp": "2024-01-15T10:30:00Z", |
390 | | - "app-version": "1.0.0" |
391 | | -} |
392 | | - |
393 | | -with open(f"{iexec_out}/computed.json", 'w') as f: |
394 | | - json.dump(computed_metadata, f) |
395 | | -``` |
396 | | - |
397 | | -```javascript [JavaScript] |
398 | | -const fs = require('fs'); |
399 | | -const path = require('path'); |
400 | | - |
401 | | -// Get output directory |
402 | | -const iexecOut = process.env.IEXEC_OUT; |
403 | | - |
404 | | -// Create your result file |
405 | | -const resultData = { |
406 | | - analysis: 'positive sentiment', |
407 | | - confidence: 0.92, |
408 | | - processed_at: '2024-01-15T10:30:00Z', |
409 | | -}; |
410 | | - |
411 | | -// Save main result |
412 | | -fs.writeFileSync( |
413 | | - path.join(iexecOut, 'result.json'), |
414 | | - JSON.stringify(resultData, null, 2) |
415 | | -); |
416 | | - |
417 | | -// REQUIRED: Create computed.json metadata |
418 | | -const computedMetadata = { |
419 | | - 'deterministic-output-path': path.join(iexecOut, 'result.json'), |
420 | | - 'execution-timestamp': '2024-01-15T10:30:00Z', |
421 | | - 'app-version': '1.0.0', |
422 | | -}; |
423 | | - |
424 | | -fs.writeFileSync( |
425 | | - path.join(iexecOut, 'computed.json'), |
426 | | - JSON.stringify(computedMetadata, null, 2) |
427 | | -); |
428 | | -``` |
429 | | - |
430 | | -::: |
431 | | - |
432 | | -### Output Best Practices |
433 | | - |
434 | | -1. **Always create `computed.json`** - This is mandatory |
435 | | -2. **Use descriptive filenames** - `analysis_result.json`, not `output.txt` |
436 | | -3. **Include metadata** - Timestamps, versions, parameters used |
437 | | -4. **Structure your data** - Use JSON for structured results |
438 | | -5. **Keep files reasonable** - Large outputs increase retrieval time and may hit |
439 | | - memory limits |
440 | | -6. **Memory awareness** - TEE enclave memory is limited, avoid generating |
441 | | - multi-GB outputs |
442 | | - |
443 | | -### Example: Multi-file Output |
444 | | - |
445 | | -```python |
446 | | -import os |
447 | | -import json |
448 | | - |
449 | | -iexec_out = os.environ['IEXEC_OUT'] |
450 | | - |
451 | | -# Create multiple output files |
452 | | -summary = {"total_processed": 1000, "success_rate": 0.95} |
453 | | -with open(f"{iexec_out}/summary.json", 'w') as f: |
454 | | - json.dump(summary, f) |
455 | | - |
456 | | -# Create a detailed report |
457 | | -with open(f"{iexec_out}/detailed_report.txt", 'w') as f: |
458 | | - f.write("Detailed analysis results...\n") |
459 | | - |
460 | | -# Create visualization data |
461 | | -chart_data = {"labels": ["A", "B", "C"], "values": [10, 20, 30]} |
462 | | -with open(f"{iexec_out}/chart_data.json", 'w') as f: |
463 | | - json.dump(chart_data, f) |
464 | | - |
465 | | -# Required metadata file |
466 | | -computed = { |
467 | | - "deterministic-output-path": f"{iexec_out}/summary.json", |
468 | | - "additional-files": [ |
469 | | - f"{iexec_out}/detailed_report.txt", |
470 | | - f"{iexec_out}/chart_data.json" |
471 | | - ] |
472 | | -} |
473 | | -with open(f"{iexec_out}/computed.json", 'w') as f: |
474 | | - json.dump(computed, f) |
475 | | -``` |
476 | | - |
477 | 359 | ## Testing Inputs Locally |
478 | 360 |
|
479 | 361 | Use iApp Generator to test different input types: |
@@ -595,13 +477,13 @@ save_report(report) |
595 | 477 |
|
596 | 478 | ## What's Next? |
597 | 479 |
|
598 | | -**You now understand all input types and output requirements!** |
| 480 | +**You now understand all input types available to your iApp!** |
599 | 481 |
|
600 | 482 | Continue building with these guides: |
601 | 483 |
|
| 484 | +- **[Outputs](/guides/build-iapp/outputs)** - Learn how to generate and |
| 485 | + structure your iApp outputs |
602 | 486 | - **[App Access Control and Pricing](/guides/build-iapp/manage-access)** - |
603 | 487 | Control who can use your iApp |
604 | 488 | - **[Debugging Your iApp](/guides/build-iapp/debugging)** - Troubleshoot |
605 | 489 | execution issues |
606 | | -- **[How to Get and Decrypt Results](/guides/build-iapp/inputs-and-outputs)** - |
607 | | - User-side result handling |
0 commit comments