@@ -164,7 +164,7 @@ sufficient funds for this transfer to proceed.
164164
165165** Type:** ` Address `
166166
167- This optional parameter allows you to pay for the task using someone else’ s
167+ This optional parameter allows you to pay for the task using someone else' s
168168voucher. Make sure the voucher's owner has authorized you to use it. This
169169parameter must be used in combination with ` useVoucher: true ` .
170170
@@ -183,6 +183,92 @@ const processProtectedDataResponse =
183183 });
184184```
185185
186+ ### encryptResult <OptionalBadge />
187+
188+ ** Type:** ` boolean `
189+ ** Default:** ` false `
190+
191+ When set to ` true ` , the computation result will be encrypted using RSA
192+ encryption. This ensures that only you can decrypt and access the result,
193+ providing an additional layer of privacy and security for sensitive computation
194+ outputs.
195+
196+ If ` encryptResult ` is ` true ` and no ` pemPrivateKey ` is provided, a new RSA key
197+ pair will be automatically generated. The generated private key will be returned
198+ in the response as ` pemPrivateKey ` , which you must securely store to decrypt the
199+ result later.
200+
201+ ``` ts twoslash
202+ import { IExecDataProtectorCore , getWeb3Provider } from ' @iexec/dataprotector' ;
203+
204+ const web3Provider = getWeb3Provider (' PRIVATE_KEY' );
205+ const dataProtectorCore = new IExecDataProtectorCore (web3Provider );
206+ // ---cut---
207+ const processProtectedDataResponse =
208+ await dataProtectorCore .processProtectedData ({
209+ protectedData: ' 0x123abc...' ,
210+ app: ' 0x456def...' ,
211+ encryptResult: true , // [!code focus]
212+ });
213+ ```
214+
215+ ::: tip
216+
217+ When ` encryptResult ` is enabled, the ` onStatusUpdate ` callback will be notified
218+ with the following additional status titles:
219+
220+ - ` 'GENERATE_ENCRYPTION_KEY' ` - When a new key pair is being generated
221+ - ` 'PUSH_ENCRYPTION_KEY' ` - When the public key is being pushed to the secrets
222+ manager
223+
224+ :::
225+
226+ ### pemPrivateKey <OptionalBadge />
227+
228+ ** Type:** ` string `
229+
230+ A PEM-formatted RSA private key used to decrypt the encrypted computation
231+ result. This parameter can only be used when ` encryptResult ` is set to ` true ` .
232+
233+ If you provide a ` pemPrivateKey ` , it will be used to decrypt the result. If you
234+ don't provide one but have ` encryptResult: true ` , a new key pair will be
235+ generated automatically, and the private key will be returned in the response
236+ for you to store securely.
237+
238+ ``` ts twoslash
239+ import { IExecDataProtectorCore , getWeb3Provider } from ' @iexec/dataprotector' ;
240+
241+ const web3Provider = getWeb3Provider (' PRIVATE_KEY' );
242+ const dataProtectorCore = new IExecDataProtectorCore (web3Provider );
243+ // ---cut---
244+ const processProtectedDataResponse =
245+ await dataProtectorCore .processProtectedData ({
246+ protectedData: ' 0x123abc...' ,
247+ app: ' 0x456def...' ,
248+ encryptResult: true , // [!code focus]
249+ pemPrivateKey:
250+ ' -----BEGIN PRIVATE KEY-----\n ...\n -----END PRIVATE KEY-----' , // [!code focus]
251+ });
252+ ```
253+
254+ ::: danger
255+
256+ If you provide a ` pemPrivateKey ` , you must also set ` encryptResult: true ` . The
257+ method will throw a validation error if ` pemPrivateKey ` is provided without
258+ ` encryptResult ` being enabled.
259+
260+ :::
261+
262+ ::: tip
263+
264+ The ` pemPrivateKey ` (whether provided or auto-generated) will be included in the
265+ response object when ` encryptResult ` is ` true ` . Make sure to securely store this
266+ key if you need to decrypt the result later using the
267+ [ getResultFromCompletedTask()] ( /references/dataProtector/methods/getResultFromCompletedTask )
268+ method.
269+
270+ :::
271+
186272### args <OptionalBadge />
187273
188274** Type:** ` string `
@@ -422,18 +508,26 @@ const processProtectedDataResponse = await dataProtectorCore.processProtectedDat
422508You can expect this callback function to be called with the following titles:
423509
424510``` ts
425- ' FETCH_PROTECTED_DATA_ORDERBOOK' ;
426- ' FETCH_APP_ORDERBOOK' ;
427- ' FETCH_WORKERPOOL_ORDERBOOK' ;
511+ ' FETCH_ORDERS' ;
428512' PUSH_REQUESTER_SECRET' ;
513+ ' GENERATE_ENCRYPTION_KEY' ;
514+ ' PUSH_ENCRYPTION_KEY' ;
429515' REQUEST_TO_PROCESS_PROTECTED_DATA' ;
516+ ' TASK_EXECUTION' ;
430517' CONSUME_TASK' ;
431518' CONSUME_RESULT_DOWNLOAD' ;
432519' CONSUME_RESULT_DECRYPT' ;
433520```
434521
435522Once with ` isDone: false ` , and then with ` isDone: true `
436523
524+ ::: info
525+
526+ The ` 'GENERATE_ENCRYPTION_KEY' ` and ` 'PUSH_ENCRYPTION_KEY' ` status titles are
527+ only triggered when ` encryptResult ` is set to ` true ` .
528+
529+ :::
530+
437531## Return Value
438532
439533``` ts twoslash
@@ -492,6 +586,27 @@ processed during the task.
492586
493587:::
494588
589+ ### pemPrivateKey
590+
591+ ` string `
592+
593+ The PEM-formatted RSA private key used to decrypt the encrypted computation
594+ result. This property is only present in the response when ` encryptResult ` is
595+ set to ` true ` .
596+
597+ If you provided a ` pemPrivateKey ` in the parameters, the same key will be
598+ returned. If you didn't provide one but enabled ` encryptResult ` , a newly
599+ generated private key will be returned, which you must securely store to decrypt
600+ the result.
601+
602+ ::: tip
603+
604+ You can use this ` pemPrivateKey ` with the
605+ [ getResultFromCompletedTask()] ( /references/dataProtector/methods/getResultFromCompletedTask )
606+ method to decrypt and retrieve the result of a completed task.
607+
608+ :::
609+
495610<script setup >
496611import { computed } from ' vue' ;
497612import RequiredBadge from ' @/components/RequiredBadge.vue'
0 commit comments