Skip to main content
Glama

encryptNip44

Encrypt text messages for secure private communication on Nostr using NIP-44 encryption standard. Send encrypted content to specific recipients using their public key.

Instructions

Encrypt text with NIP-44

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
plaintextYesText to encrypt
recipientPubkeyYesRecipient pubkey (hex or npub)
privateKeyNoPrivate key (nsec or hex). Optional when NOSTR_BUNKER_URI is configured.

Implementation Reference

  • The function 'encryptNip44Fn' that executes the NIP-44 encryption logic.
    export async function encryptNip44Fn({ plaintext, recipientPubkey, privateKey }: z.infer<typeof encryptNip44Schema>) {
      const recipient = normalizePubkey(recipientPubkey);
      if (isBunkerMode()) {
        return nip44EncryptWithBunker(recipient, plaintext);
      }
      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, recipient);
      return nip44.v2.encrypt(plaintext, conversationKey);
    }
  • The Zod schema 'encryptNip44Schema' defining inputs for the 'encryptNip44' tool.
    export const encryptNip44Schema = z.object({
      plaintext: z.string().describe('Text to encrypt'),
      recipientPubkey: z.string().describe('Recipient pubkey (hex or npub)'),
      privateKey: z.string().optional().describe(privateKeyDesc),
    });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jorgenclaw/nostr-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server