Skip to main content
Glama
Zetrix-Chain

Zetrix MCP Server

Official
by Zetrix-Chain

zetrix_crypto_encrypt_key

Encrypt private keys with passwords for secure storage on the Zetrix blockchain, protecting sensitive cryptographic data from unauthorized access.

Instructions

Encrypt a private key with a password for secure storage

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
privateKeyYesThe private key to encrypt
passwordYesThe password to use for encryption

Implementation Reference

  • src/index.ts:623-640 (registration)
    Tool registration in the MCP tools list, including name, description, and input schema definition
    {
      name: "zetrix_crypto_encrypt_key",
      description: "Encrypt a private key with a password for secure storage",
      inputSchema: {
        type: "object",
        properties: {
          privateKey: {
            type: "string",
            description: "The private key to encrypt",
          },
          password: {
            type: "string",
            description: "The password to use for encryption",
          },
        },
        required: ["privateKey", "password"],
      },
    },
  • MCP server request handler for the tool. Validates arguments and delegates to ZetrixEncryption.encryptPrivateKey, formats response
    case "zetrix_crypto_encrypt_key": {
      if (!args) {
        throw new Error("Missing arguments");
      }
      const encryptedData = await zetrixEncryption.encryptPrivateKey(
        args.privateKey as string,
        args.password as string
      );
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify({ encryptedData }, null, 2),
          },
        ],
      };
    }
  • Core implementation of private key encryption using the official zetrix-encryption-nodejs library's keystore.encrypt method, wrapped in Promise for async/await compatibility
    /**
     * Encrypt a private key with a password (uses callbacks, wrapped in Promise)
     * @param privateKey - The private key to encrypt
     * @param password - The password to use for encryption
     * @returns Encrypted keystore data (object that can be passed to decrypt)
     */
    async encryptPrivateKey(
      privateKey: string,
      password: string
    ): Promise<any> {
      await this.initEncryption();
    
      return new Promise((resolve, reject) => {
        try {
          this.keystore.encrypt(privateKey, password, (result: any) => {
            if (result) {
              // The library returns an object with encrypted data
              // Return as-is for decrypt to consume
              resolve(result);
            } else {
              reject(new Error("Encryption failed: No data returned"));
            }
          });
        } catch (error) {
          reject(
            new Error(
              `Failed to encrypt private key: ${error instanceof Error ? error.message : String(error)}`
            )
          );
        }
      });
    }

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/Zetrix-Chain/zetrix-mcp-server'

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