Skip to content

Commit c1de0b1

Browse files
committed
docs: enhance processProtectedData documentation with encryptResult and pemPrivateKey details
1 parent 3b05589 commit c1de0b1

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

src/references/dataProtector/methods/processProtectedData.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,92 @@ const processProtectedDataResponse =
128128
});
129129
```
130130

131+
### encryptResult <OptionalBadge />
132+
133+
**Type:** `boolean`
134+
**Default:** `false`
135+
136+
When set to `true`, the computation result will be encrypted using RSA
137+
encryption. This ensures that only you can decrypt and access the result,
138+
providing an additional layer of privacy and security for sensitive computation
139+
outputs.
140+
141+
If `encryptResult` is `true` and no `pemPrivateKey` is provided, a new RSA key
142+
pair will be automatically generated. The generated private key will be returned
143+
in the response as `pemPrivateKey`, which you must securely store to decrypt the
144+
result later.
145+
146+
```ts twoslash
147+
import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector';
148+
149+
const web3Provider = getWeb3Provider('PRIVATE_KEY');
150+
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
151+
// ---cut---
152+
const processProtectedDataResponse =
153+
await dataProtectorCore.processProtectedData({
154+
protectedData: '0x123abc...',
155+
app: '0x456def...',
156+
encryptResult: true, // [!code focus]
157+
});
158+
```
159+
160+
::: tip
161+
162+
When `encryptResult` is enabled, the `onStatusUpdate` callback will be notified
163+
with the following additional status titles:
164+
165+
- `'GENERATE_ENCRYPTION_KEY'` - When a new key pair is being generated
166+
- `'PUSH_ENCRYPTION_KEY'` - When the public key is being pushed to the secrets
167+
manager
168+
169+
:::
170+
171+
### pemPrivateKey <OptionalBadge />
172+
173+
**Type:** `string`
174+
175+
A PEM-formatted RSA private key used to decrypt the encrypted computation
176+
result. This parameter can only be used when `encryptResult` is set to `true`.
177+
178+
If you provide a `pemPrivateKey`, it will be used to decrypt the result. If you
179+
don't provide one but have `encryptResult: true`, a new key pair will be
180+
generated automatically, and the private key will be returned in the response
181+
for you to store securely.
182+
183+
```ts twoslash
184+
import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector';
185+
186+
const web3Provider = getWeb3Provider('PRIVATE_KEY');
187+
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
188+
// ---cut---
189+
const processProtectedDataResponse =
190+
await dataProtectorCore.processProtectedData({
191+
protectedData: '0x123abc...',
192+
app: '0x456def...',
193+
encryptResult: true, // [!code focus]
194+
pemPrivateKey:
195+
'-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----', // [!code focus]
196+
});
197+
```
198+
199+
::: danger
200+
201+
If you provide a `pemPrivateKey`, you must also set `encryptResult: true`. The
202+
method will throw a validation error if `pemPrivateKey` is provided without
203+
`encryptResult` being enabled.
204+
205+
:::
206+
207+
::: tip
208+
209+
The `pemPrivateKey` (whether provided or auto-generated) will be included in the
210+
response object when `encryptResult` is `true`. Make sure to securely store this
211+
key if you need to decrypt the result later using the
212+
[getResultFromCompletedTask()](/references/dataProtector/methods/getResultFromCompletedTask)
213+
method.
214+
215+
:::
216+
131217
### args <OptionalBadge />
132218

133219
**Type:** `string`

0 commit comments

Comments
 (0)