Skip to content

Commit d7618b8

Browse files
committed
feat(docs): add wrapped-keys reference
1 parent 023e305 commit d7618b8

11 files changed

+474
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: batchGeneratePrivateKeys
3+
---
4+
5+
# Function
6+
7+
> **batchGeneratePrivateKeys**(`params`)
8+
9+
Runs multiple wrapped-key actions in one request, optionally signing messages as part of the batch.
10+
11+
## Parameters
12+
13+
<ParamField path="params.pkpSessionSigs" type="SessionSigsMap" required />
14+
<ParamField path="params.litClient" type="LitClient" required />
15+
<ParamField path="params.actions" type="GeneratePrivateKeyAction[]" required>
16+
Each action may specify `network`, `generateKeyParams.memo`, and optional `signMessageParams.messageToSign`.
17+
</ParamField>
18+
<ParamField path="params.userMaxPrice" type="bigint">
19+
Optional `executeJs` price cap (applies to the whole batch).
20+
</ParamField>
21+
22+
## Returns
23+
24+
<ResponseField name="result" type="BatchGeneratePrivateKeysResult">
25+
<Expandable title="properties" defaultOpen={true}>
26+
<ResponseField name="pkpAddress" type="string" required />
27+
<ResponseField name="results" type="BatchGeneratePrivateKeysActionResult[]" required />
28+
</Expandable>
29+
</ResponseField>
30+
31+
## Example
32+
33+
```ts
34+
const { results } = await wrappedKeysApi.batchGeneratePrivateKeys({
35+
pkpSessionSigs,
36+
litClient,
37+
actions: [
38+
{ network: 'evm', generateKeyParams: { memo: 'key-0' } },
39+
],
40+
});
41+
```
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: exportPrivateKey
3+
---
4+
5+
# Function
6+
7+
> **exportPrivateKey**(`params`)
8+
9+
Decrypts a previously stored wrapped key in a Lit Action and returns the plaintext private key together with metadata.
10+
11+
## Parameters
12+
13+
<ParamField path="params.pkpSessionSigs" type="SessionSigsMap" required>
14+
Session signatures proving the PKP owns the wrapped key.
15+
</ParamField>
16+
17+
<ParamField path="params.litClient" type="LitClient" required>
18+
Lit client connected to the network that holds the encrypted key.
19+
</ParamField>
20+
21+
<ParamField path="params.network" type="'evm' | 'solana'" required>
22+
Selects the Lit Action that knows how to handle the key type.
23+
</ParamField>
24+
25+
<ParamField path="params.id" type="string" required>
26+
Identifier returned from `generatePrivateKey`, `importPrivateKey`, or `storeEncryptedKey`.
27+
</ParamField>
28+
29+
<ParamField path="params.userMaxPrice" type="bigint">
30+
Optional spending cap passed to the underlying `executeJs` call.
31+
</ParamField>
32+
33+
## Returns
34+
35+
<ResponseField name="result" type="ExportPrivateKeyResult">
36+
<Expandable title="properties" defaultOpen={true}>
37+
<ResponseField name="decryptedPrivateKey" type="string" required />
38+
<ResponseField name="pkpAddress" type="string" required />
39+
<ResponseField name="publicKey" type="string" required />
40+
<ResponseField name="keyType" type="'K256' | 'ed25519'" required />
41+
<ResponseField name="memo" type="string" required />
42+
<ResponseField name="id" type="string" required />
43+
</Expandable>
44+
</ResponseField>
45+
46+
## Example
47+
48+
```ts
49+
const { decryptedPrivateKey } = await wrappedKeysApi.exportPrivateKey({
50+
pkpSessionSigs,
51+
litClient,
52+
network: 'evm',
53+
id,
54+
});
55+
```
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: generatePrivateKey
3+
---
4+
5+
# Function
6+
7+
> **generatePrivateKey**(`params`)
8+
9+
Generates a new wrapped key inside a Lit Action, stores the encrypted payload, and returns the wrapped-key identifier together with the generated public key.
10+
11+
## Parameters
12+
13+
<ParamField path="params.pkpSessionSigs" type="SessionSigsMap" required>
14+
Session signatures produced for the PKP that should own the wrapped key.
15+
</ParamField>
16+
17+
<ParamField path="params.litClient" type="LitClient" required>
18+
The Lit client instance used to execute the Lit Action and resolve the target network cluster.
19+
</ParamField>
20+
21+
<ParamField path="params.network" type="'evm' | 'solana'" required>
22+
Determines which Lit Action to run and which key type to generate.
23+
</ParamField>
24+
25+
<ParamField path="params.memo" type="string" required>
26+
Free-form description stored alongside the encrypted key metadata.
27+
</ParamField>
28+
29+
<ParamField path="params.userMaxPrice" type="bigint">
30+
Optional cap on the price you are willing to pay for the underlying `executeJs` request.
31+
</ParamField>
32+
33+
## Returns
34+
35+
<ResponseField name="result" type="GeneratePrivateKeyResult">
36+
<Expandable title="properties" defaultOpen={true}>
37+
<ResponseField name="id" type="string" required>
38+
Wrapped-key identifier that can be used to fetch or sign with the stored key.
39+
</ResponseField>
40+
<ResponseField name="pkpAddress" type="string" required>
41+
PKP address associated with the wrapped key (derived from the session signatures).
42+
</ResponseField>
43+
<ResponseField name="generatedPublicKey" type="string" required>
44+
Public key for the newly generated private key.
45+
</ResponseField>
46+
</Expandable>
47+
</ResponseField>
48+
49+
## Example
50+
51+
```ts
52+
const { id, generatedPublicKey } = await wrappedKeysApi.generatePrivateKey({
53+
pkpSessionSigs,
54+
litClient,
55+
network: 'evm',
56+
memo: 'relayer wallet',
57+
});
58+
```
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: getEncryptedKey
3+
---
4+
5+
# Function
6+
7+
> **getEncryptedKey**(`params`)
8+
9+
Fetches the encrypted ciphertext and metadata for a stored wrapped key without decrypting it.
10+
11+
## Parameters
12+
13+
<ParamField path="params.pkpSessionSigs" type="SessionSigsMap" required>
14+
Session signatures identifying the PKP that owns the wrapped key.
15+
</ParamField>
16+
17+
<ParamField path="params.litClient" type="LitClient" required>
18+
Lit client instance used to talk to the wrapped-keys service.
19+
</ParamField>
20+
21+
<ParamField path="params.id" type="string" required>
22+
Identifier of the wrapped key to retrieve.
23+
</ParamField>
24+
25+
<ParamField path="params.userMaxPrice" type="bigint">
26+
Optional price ceiling for the Lit Action.
27+
</ParamField>
28+
29+
## Returns
30+
31+
<ResponseField name="result" type="StoredKeyData">
32+
Includes ciphertext, `dataToEncryptHash`, memo, key type, public key, and PKP address.
33+
</ResponseField>
34+
35+
## Example
36+
37+
```ts
38+
const storedKey = await wrappedKeysApi.getEncryptedKey({
39+
pkpSessionSigs,
40+
litClient,
41+
id,
42+
});
43+
```
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: importPrivateKey
3+
---
4+
5+
# Function
6+
7+
> **importPrivateKey**(`params`)
8+
9+
Encrypts an existing private key with Lit and stores it as wrapped key metadata.
10+
11+
## Parameters
12+
13+
<ParamField path="params.pkpSessionSigs" type="SessionSigsMap" required>
14+
Session signatures tying the wrapped key to the PKP.
15+
</ParamField>
16+
17+
<ParamField path="params.litClient" type="LitClient" required>
18+
Lit client instance for executing the Lit Action and accessing storage services.
19+
</ParamField>
20+
21+
<ParamField path="params.privateKey" type="string" required>
22+
Hex-encoded private key to wrap (a `0x` prefixed string for EVM keys).
23+
</ParamField>
24+
25+
<ParamField path="params.publicKey" type="string" required>
26+
Public key corresponding to the private key being wrapped.
27+
</ParamField>
28+
29+
<ParamField path="params.keyType" type="'K256' | 'ed25519'" required>
30+
Identifies the algorithm so the service can store the key correctly.
31+
</ParamField>
32+
33+
<ParamField path="params.memo" type="string" required>
34+
Description stored with the wrapped key.
35+
</ParamField>
36+
37+
<ParamField path="params.userMaxPrice" type="bigint">
38+
Optional `executeJs` price cap.
39+
</ParamField>
40+
41+
## Returns
42+
43+
<ResponseField name="result" type="ImportPrivateKeyResult">
44+
<Expandable title="properties" defaultOpen={true}>
45+
<ResponseField name="pkpAddress" type="string" required />
46+
<ResponseField name="id" type="string" required />
47+
</Expandable>
48+
</ResponseField>
49+
50+
## Example
51+
52+
```ts
53+
const { id } = await wrappedKeysApi.importPrivateKey({
54+
pkpSessionSigs,
55+
litClient,
56+
privateKey: wallet.privateKey,
57+
publicKey: wallet.publicKey,
58+
keyType: 'K256',
59+
memo: 'imported relayer key',
60+
});
61+
```
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: listEncryptedKeyMetadata
3+
---
4+
5+
# Function
6+
7+
> **listEncryptedKeyMetadata**(`params`)
8+
9+
Returns metadata for all wrapped keys owned by the PKP without downloading ciphertext.
10+
11+
## Parameters
12+
13+
<ParamField path="params.pkpSessionSigs" type="SessionSigsMap" required />
14+
<ParamField path="params.litClient" type="LitClient" required />
15+
<ParamField path="params.userMaxPrice" type="bigint">
16+
Optional price ceiling for the Lit Action.
17+
</ParamField>
18+
19+
## Returns
20+
21+
<ResponseField name="metadata" type="StoredKeyMetadata[]">
22+
Array of stored keys (id, memo, key type, public key, PKP address, network).
23+
</ResponseField>
24+
25+
## Example
26+
27+
```ts
28+
const metadata = await wrappedKeysApi.listEncryptedKeyMetadata({
29+
pkpSessionSigs,
30+
litClient,
31+
});
32+
```
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: signMessageWithEncryptedKey
3+
---
4+
5+
# Function
6+
7+
> **signMessageWithEncryptedKey**(`params`)
8+
9+
Decrypts a stored wrapped key inside a Lit Action and signs an arbitrary message.
10+
11+
## Parameters
12+
13+
<ParamField path="params.pkpSessionSigs" type="SessionSigsMap" required />
14+
<ParamField path="params.litClient" type="LitClient" required />
15+
<ParamField path="params.network" type="'evm' | 'solana'" required />
16+
<ParamField path="params.id" type="string" required />
17+
<ParamField path="params.messageToSign" type="string | Uint8Array" required />
18+
<ParamField path="params.userMaxPrice" type="bigint">
19+
Optional `executeJs` price cap.
20+
</ParamField>
21+
22+
## Returns
23+
24+
<ResponseField name="signature" type="string">
25+
Raw signature string (`0x` hex for EVM, base58 for Solana).
26+
</ResponseField>
27+
28+
## Example
29+
30+
```ts
31+
const signature = await wrappedKeysApi.signMessageWithEncryptedKey({
32+
pkpSessionSigs,
33+
litClient,
34+
network: 'evm',
35+
id,
36+
messageToSign: 'hello from wrapped keys',
37+
});
38+
```
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: signTransactionWithEncryptedKey
3+
---
4+
5+
# Function
6+
7+
> **signTransactionWithEncryptedKey**(`params`)
8+
9+
Signs an EVM or Solana transaction with a stored wrapped key. Optionally broadcasts when the Lit Action supports it.
10+
11+
## Parameters
12+
13+
<ParamField path="params.pkpSessionSigs" type="SessionSigsMap" required />
14+
<ParamField path="params.litClient" type="LitClient" required />
15+
<ParamField path="params.network" type="'evm' | 'solana'" required />
16+
<ParamField path="params.id" type="string" required />
17+
<ParamField path="params.unsignedTransaction" type="object" required>
18+
Serialized transaction payload. For Solana include `chain`/`serializedTransaction`; for EVM include `chain`, `chainId`, and `toAddress`/`value`.
19+
</ParamField>
20+
<ParamField path="params.broadcast" type="boolean" defaultValue={false}>
21+
When `true`, the Lit Action attempts to submit the signed transaction to the configured RPC endpoint and returns the transaction hash.
22+
</ParamField>
23+
<ParamField path="params.versionedTransaction" type="boolean">
24+
Set to `true` when providing a Solana versioned transaction payload.
25+
</ParamField>
26+
<ParamField path="params.userMaxPrice" type="bigint">
27+
Optional price ceiling for the Lit Action.
28+
</ParamField>
29+
30+
## Returns
31+
32+
<ResponseField name="result" type="string">
33+
Signed transaction (or hash when broadcasting is enabled).
34+
</ResponseField>
35+
36+
## Example
37+
38+
```ts
39+
const signedTx = await wrappedKeysApi.signTransactionWithEncryptedKey({
40+
pkpSessionSigs,
41+
litClient,
42+
network: 'evm',
43+
id,
44+
unsignedTransaction: {
45+
chain: 'yellowstone',
46+
chainId: 1337,
47+
toAddress: ZERO_ADDRESS,
48+
value: '0',
49+
},
50+
broadcast: false,
51+
});
52+
```

0 commit comments

Comments
 (0)