{"record":{"id":"954b7eb7f4661cb9","repo":"gchq/CyberChef","slug":"enter-the-private-key-of-the-recipient","errorCode":null,"errorMessage":"Enter the private key of the recipient.","messagePattern":"Enter the private key of the recipient\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"warning","filePath":"src/core/operations/PGPDecrypt.mjs","lineNumber":67,"sourceCode":"                \"value\": \"\"\n            }\n        ];\n    }\n\n    /**\n     * @param {string} input\n     * @param {Object[]} args\n     * @returns {string}\n     *\n     * @throws {OperationError} if invalid private key\n     */\n    async run(input, args) {\n        const encryptedMessage = input,\n            [privateKey, passphrase] = args,\n            keyring = new kbpgp.keyring.KeyRing();\n        let plaintextMessage;\n\n        if (!privateKey) throw new OperationError(\"Enter the private key of the recipient.\");\n\n        const key = await importPrivateKey(privateKey, passphrase);\n        keyring.add_key_manager(key);\n\n        try {\n            plaintextMessage = await promisify(kbpgp.unbox)({\n                armored: encryptedMessage,\n                keyfetch: keyring,\n                asp: ASP\n            });\n        } catch (err) {\n            throw new OperationError(`Couldn't decrypt message with provided private key: ${err}`);\n        }\n\n        return plaintextMessage.toString();\n    }\n\n}","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/PGPDecrypt.mjs#L49-L85","documentation":"PGPDecrypt.run reads args[0] as the recipient's private key. If it is falsy (empty string, null, undefined) the operation aborts immediately - there is nothing to decrypt with. This is an input-validation guard thrown before any crypto runs; importPrivateKey has not yet been called.","triggerScenarios":"The 'Private key of recipient' argument is left empty; the args array is shorter than expected; the key text failed to bind from the UI/recipe.","commonSituations":"User forgot to paste the private key; an automated recipe with a blank key field; copy-paste that missed the clipboard; programmatic call passing an empty string.","solutions":["Provide the recipient's ASCII-armoured PGP private key in the first argument.","If the key is passphrase-protected, also fill the passphrase field.","Verify the key block begins with '-----BEGIN PGP PRIVATE KEY BLOCK-----'."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const [privateKey, passphrase] = args;\nif (!privateKey || !privateKey.trim()) {\n    throw new Error('Private key argument is required before running PGP Decrypt.');\n}","typeGuard":"const isArmouredPrivateKey = (s) =>\n    typeof s === 'string' && /-----BEGIN PGP PRIVATE KEY BLOCK-----/.test(s);","tryCatchPattern":null,"preventionTips":["Always populate the private-key argument before running.","Validate the key is an armoured PGP private key block.","Provide a passphrase when the key is locked."],"tags":["pgp","validation","kbpgp","cryptography"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}