Skip to main content
Glama

encryptNip44

Encrypt text messages for secure Nostr communications using the NIP-44 standard. Provide plaintext and recipient public key to generate encrypted content.

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 handler function for the encryptNip44 tool, which handles both local signing and remote signing (Bunker mode).
    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);
    }
  • Schema definition for the encryptNip44 tool using Zod.
    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