Decrypting the Private Key

When you request wallet information for a master or transit wallet, the API returns the field:

private_key_encrypted: "BASE64_ENCODED_RSA_payload"

This value is a RSA-encrypted private key, encoded in Base64.

To decrypt it, you must use your own RSA private key — the one that corresponds to the public RSA key previously uploaded via:

POST /rsa/upload

The platform never stores your RSA private key, and only you can decrypt the wallet’s private key.


Encryption Details

  • Algorithm: RSA-OAEP

  • Hash function: SHA-256

  • Output: Base64-encoded encrypted payload

  • Input (before encryption): raw wallet private key (hex string)


How to Decrypt (General Flow)

  1. Convert the Base64 string to binary

  2. Use your RSA private key to decrypt the ciphertext

  3. The result is a raw wallet private key (hex string)

import crypto from "crypto";

const encrypted = "BASE64_PAYLOAD_HERE"; // private_key_encrypted
const privateKey = `
-----BEGIN PRIVATE KEY-----
YOUR_RSA_PRIVATE_KEY_CONTENT
-----END PRIVATE KEY-----
`;

const decrypted = crypto.privateDecrypt(
  {
    key: privateKey,
    padding: crypto.constants.RSA_PKCS1_OAEP_PADDING,
    oaepHash: "sha256"
  },
  Buffer.from(encrypted, "base64")
);

console.log("Wallet Private Key:", decrypted.toString());

Last updated