zetrix_crypto_decrypt_key
Decrypt an encrypted private key using a password to access Zetrix blockchain accounts securely.
Instructions
Decrypt an encrypted private key with a password
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| encryptedData | Yes | The encrypted keystore data | |
| password | Yes | The password used for encryption |
Implementation Reference
- src/index.ts:1365-1381 (handler)MCP server tool handler case that executes the decryption by calling ZetrixEncryption.decryptPrivateKeycase "zetrix_crypto_decrypt_key": { if (!args) { throw new Error("Missing arguments"); } const privateKey = await zetrixEncryption.decryptPrivateKey( args.encryptedData, // Can be object or string args.password as string ); return { content: [ { type: "text", text: JSON.stringify({ privateKey }, null, 2), }, ], }; }
- src/index.ts:641-658 (registration)Tool registration in the MCP tools list, including name, description, and input schema{ name: "zetrix_crypto_decrypt_key", description: "Decrypt an encrypted private key with a password", inputSchema: { type: "object", properties: { encryptedData: { type: "string", description: "The encrypted keystore data", }, password: { type: "string", description: "The password used for encryption", }, }, required: ["encryptedData", "password"], }, },
- src/zetrix-encryption.ts:241-265 (helper)Core helper function implementing decryption logic using zetrix-encryption-nodejs library's keystore.decrypt with Promise wrapperasync decryptPrivateKey( encryptedData: any, password: string ): Promise<string> { await this.initEncryption(); return new Promise((resolve, reject) => { try { // The decrypt function accepts the object directly this.keystore.decrypt(encryptedData, password, (decrypted: string) => { if (decrypted) { resolve(decrypted); } else { reject(new Error("Decryption failed: Invalid password or data")); } }); } catch (error) { reject( new Error( `Failed to decrypt private key: ${error instanceof Error ? error.message : String(error)}` ) ); } }); }