1. Decrypt the Octet Key
When you call the Get Octet Key API, the Octet key value is returned. At this point, the returned value is the Octet key encrypted with the RSA private key.
You can download the RSA public key on the [Developer Tools] - [Encryption Key] page of the Octet console.
Use that key to decrypt as shown below.
Example
import { readFileSync } from 'fs';
import { publicDecrypt } from 'crypto';
// Change the path as needed
const publicKey = readFileSync('/Users/sam/Downloads/[MAINNET]Octet_RSA_Pub_Key.pem');
// The encrypted Octet key obtained from the Get Octet Key API
const encryptedOctetKey = 'fROQ/fxCFnfB1uVobs8tdjj/43q5KU9gvY/JigmCrT2AJUWFbnSQrgNoCjwZ+wtaCwj+2GXPmy6s/1qb/VBA1jHtYeAAAeT7bkZrGZYCVZtsWGMRqIq4GiMqOhzolGvfdg+txP0PxIsVdvniC9MamGO5NibBroSNd1he39OhDncCtcVR+D8pZgDIsj9pwj4hwSJNt5t0KuGIBYQWfzDziTDOYej9FP4odPMvZWy4ISVPmf3w6KiqLr6G84loqNE04CaurvUfglzimD1tv4/HkgYksrDfzU0b9yy+XdzXXX7u06n4f9OplfQOrn+vzjrAe3GlHATx3NS7XzJr7qaJZvN9tkmE7V07Sjjk43EfMY76Nz1JItDFlERQorOAuJadwz6xxXTMJaq8K42bMv719xy5ix8Y4oU2aghuQCXgyGy5c13NTWUdjxdanbrM10f0TVuvNxzQhXBezaU3BpzWgaApl8ornNtzHowRmb+v6e9HqG6ZBlcmkZqi/z2x62JX';
const octetKey = publicDecrypt(publicKey, Buffer.from(encryptedOctetKey, 'base64')).toString('utf8')