Skip to main content

Overview

Wrapped keys let you generate, import, store, and use non-PKP private keys while keeping them encrypted by the Lit Network. The @lit-protocol/wrapped-keys package exposes helper APIs that run curated Lit Actions via executeJs for you so that signed messages or transactions never leave the Lit node unless you explicitly export the key material. Unlike the Core API flows (pkpSign, executeJs, encryptAndDecrypt) that accept an authContext directly, the wrapped-keys APIs expect a PKP session signature bundle (pkpSessionSigs). This keeps the SDK compatible with the v7 infrastructure and Lambda/serverless deployments that pass session materials between runtimes. Mint the bundle with authManager.createPkpSessionSigs as shown below.

How the flow differs from other Core API methods

  • Why generate a delegation auth sig?
    You delegate your PKP to an ephemeral session key so the wrapped-keys Lit Actions can execute without presenting your long-lived auth credentials. The delegation constrains the permissions (pkp-signing, lit-action-execution, access-control-condition-decryption) and sets an expiry window, limiting blast radius if the session key is ever leaked. Refer to the Lit resources guide for the full catalogue of resource prefixes and abilities.
  • Why supply PKP session signatures?
    Wrapped-keys endpoints reuse the same session bundle across all networks (for example, Lambda functions in the v7 stack). Provide pkpSessionSigs produced by authManager.createPkpSessionSigs so the Lit nodes can verify the delegated permissions before executing the action.
  • Controlling network spend
    Because every wrapped-keys helper ultimately calls executeJs, you can supply an optional userMaxPrice to cap how much a caller is willing to pay for node execution (mirroring the parameter available on the core executeJs API).
  • Optional: bundle Lit Action source
    By default the SDK references IPFS CIDs. To remove the IPFS dependency, inject the Lit Action source code at runtime:

Session material workflow

Wrapped-keys calls need pkpSessionSigs explicitly. Other Lit APIs that accept an authContext (for example executeJs or pkpSign) creates session signatures internally, so you do not need to export it when you are not touching wrapped keys.
Need a backend to create fresh session signatures on demand? Follow the server sessions guide to delegate a session key and let the server recreate pkpSessionSigs per request.

Example usage

Generate and sign on EVM

Generate and sign on Solana

API catalogue

See the full reference for every helper at Wrapped Keys Reference.