decryptNip44
Decrypt NIP-44 encrypted messages on Nostr using sender's public key and your private key to access secure communications.
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 implementation of the `decryptNip44Fn` handler, which decrypts NIP-44 ciphertext using either the Bunker signer or local key decryption.
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)The schema definition 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-142 (registration)Tool registration for `decryptNip44` in the MCP server.
server.tool('decryptNip44', 'Decrypt NIP-44 ciphertext', decryptNip44Schema.shape, async (params) => { return textResult({ decrypted: await decryptNip44Fn(params) });