zetrix_crypto_validate_key
Validate Zetrix blockchain private keys, public keys, or addresses to ensure correct format and prevent transaction errors.
Instructions
Validate private key, public key, or address format
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | Yes | Type of key to validate | |
| value | Yes | The key or address to validate |
Implementation Reference
- src/index.ts:1284-1308 (handler)Handler function for the zetrix_crypto_validate_key tool. Validates the input type (privateKey, publicKey, or address) and delegates to the corresponding validation method in ZetrixEncryption.case "zetrix_crypto_validate_key": { if (!args) { throw new Error("Missing arguments"); } let isValid = false; const type = args.type as string; const value = args.value as string; if (type === "privateKey") { isValid = await zetrixEncryption.isValidPrivateKey(value); } else if (type === "publicKey") { isValid = await zetrixEncryption.isValidPublicKey(value); } else if (type === "address") { isValid = await zetrixEncryption.isValidAddress(value); } return { content: [ { type: "text", text: JSON.stringify({ type, value, isValid }, null, 2), }, ], }; }
- src/index.ts:564-582 (registration)Tool registration in the tools array, defining name, description, and input schema for MCP server.{ name: "zetrix_crypto_validate_key", description: "Validate private key, public key, or address format", inputSchema: { type: "object", properties: { type: { type: "string", enum: ["privateKey", "publicKey", "address"], description: "Type of key to validate", }, value: { type: "string", description: "The key or address to validate", }, }, required: ["type", "value"], }, },
- src/index.ts:567-581 (schema)Input schema defining the expected parameters: type (enum) and value.inputSchema: { type: "object", properties: { type: { type: "string", enum: ["privateKey", "publicKey", "address"], description: "Type of key to validate", }, value: { type: "string", description: "The key or address to validate", }, }, required: ["type", "value"], },
- src/zetrix-encryption.ts:115-123 (helper)Core validation logic for private keys using the zetrix-encryption-nodejs KeyPair.checkEncPrivateKey method.async isValidPrivateKey(privateKey: string): Promise<boolean> { await this.initEncryption(); try { return this.KeyPair.checkEncPrivateKey(privateKey); } catch (error) { return false; } }
- src/zetrix-encryption.ts:130-138 (helper)Core validation logic for public keys using the zetrix-encryption-nodejs KeyPair.checkEncPublicKey method.async isValidPublicKey(publicKey: string): Promise<boolean> { await this.initEncryption(); try { return this.KeyPair.checkEncPublicKey(publicKey); } catch (error) { return false; } }
- src/zetrix-encryption.ts:145-153 (helper)Core validation logic for addresses using the zetrix-encryption-nodejs KeyPair.checkAddress method.async isValidAddress(address: string): Promise<boolean> { await this.initEncryption(); try { return this.KeyPair.checkAddress(address); } catch (error) { return false; } }