Derive a Lit Action Public Key Locally
Question
I want to callLit.Actions.signAsAction. I know the action identity is derived from the Action’s IPFS CID, but I cannot find a way to obtain the public key outside of the Action runtime. Lit.Actions.getActionPublicKey works within the Action, while executeJs only exposes signatures.<name>.publicKey after a signing operation. Is there a way to deterministically derive the Action’s public key locally without running the Action?
Answer
Yes. Inside the Lit Action you can deterministically derive the Action identity (and therefore its public key) from the same inputs the nodes use: the Action’s IPFS CID and the signing scheme. The snippet below shows the complete flow:- Produce the 32-byte message hash the Lit nodes expect.
- Call
Lit.Actions.signAsActionto sign that message with the Action identity. - Derive the Action public key via
Lit.Actions.getActionPublicKey, passing the Action CID and signing scheme. - Optionally verify the signature with
Lit.Actions.verifyActionSignature.
Lit.Actions.getActionPublicKey for a deterministic identity without needing to execute the Action externally first.
Derive the Same Public Key from Client Code
If you prefer to resolve the Lit Action public key outside of the Action runtime - e.g., inside tests or other tooling—the SDK now exposes a helper that calls the on-chain PubkeyRouter contract.getDerivedKeyId routes through PubkeyRouter.getDerivedPubkey, passing the staking contract address and the default Naga key set (naga-keyset1) (will be dynamic in the future). This mirrors the same key derivation the nodes perform, letting you confirm identities or signatures without re-running the Lit Action.