decryptNip44
Decrypt NIP-44 encrypted messages on the Nostr protocol using sender public key and private key to access secure content.
Instructions
Decrypt NIP-44 ciphertext
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ciphertext | Yes | NIP-44 encrypted text | |
| senderPubkey | Yes | Sender pubkey (hex or npub) | |
| privateKey | No | Private key (nsec or hex). Optional when NOSTR_BUNKER_URI is configured. |
Implementation Reference
- src/tools/dm-tools.ts:119-128 (handler)The handler function `decryptNip44Fn` that performs the NIP-44 decryption logic, supporting both direct key and bunker signing modes.
export async function decryptNip44Fn({ ciphertext, senderPubkey, privateKey }: z.infer<typeof decryptNip44Schema>) { const sender = normalizePubkey(senderPubkey); if (isBunkerMode()) { return nip44DecryptWithBunker(sender, ciphertext); } if (!privateKey) throw new Error('privateKey is required when NOSTR_BUNKER_URI is not configured'); const sk = normalizePrivateKey(privateKey); const conversationKey = nip44.v2.utils.getConversationKey(sk, sender); return nip44.v2.decrypt(ciphertext, conversationKey); } - src/tools/dm-tools.ts:45-49 (schema)Input validation schema for the decryptNip44 tool.
export const decryptNip44Schema = z.object({ ciphertext: z.string().describe('NIP-44 encrypted text'), senderPubkey: z.string().describe('Sender pubkey (hex or npub)'), privateKey: z.string().optional().describe(privateKeyDesc), }); - src/index.ts:141-143 (registration)Registration of the 'decryptNip44' tool in the MCP server instance.
server.tool('decryptNip44', 'Decrypt NIP-44 ciphertext', decryptNip44Schema.shape, async (params) => { return textResult({ decrypted: await decryptNip44Fn(params) }); });