-
const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----
...
-----END PGP PUBLIC KEY BLOCK-----`;
const privateKeyArmored = `-----BEGIN PGP PRIVATE KEY BLOCK-----
...
-----END PGP PRIVATE KEY BLOCK-----`; // encrypted private key
const passphrase = `yourPassphrase`; // what the private key is encrypted with
const body = 'I walk around';
const resolvedPublicKey = await readKey({ armoredKey: publicKeyArmored });
const pgpMessage = await createMessage({ text: body });
const encryptBody = {
message: pgpMessage,
encryptionKeys: resolvedPublicKey,
}
console.log('encryptBody.encryptionKeyIDs', encryptBody.encryptionKeys) // Objectful
console.log('encryptBody.signingKeyIDs', encryptBody.signingKeys) // undefined
const encryptedBody = await encrypt(encryptBody);
const resolvedPrivateKey = await readPrivateKey({ armoredKey: privateKeyArmored });
const decryptedPrivateKey = await decryptKey({
privateKey: resolvedPrivateKey,
passphrase
});
encryptBody.signingKeys = decryptedPrivateKey
console.log('encryptBody.encryptionKeyIDs', encryptBody.encryptionKeys) // Objectful
console.log('encryptBody.signingKeyIDs', encryptBody.signingKeys) // Objectful
const encryptedBodySecond = await encrypt(encryptBody);
const message = await readMessage({
armoredMessage: encryptedBodySecond // parse armored message
});
console.log('message', message) // Object of stuff
console.log('message.armor', message.armor()) // []
console.log('message.getEncryptionKeyIDs', message.getEncryptionKeyIDs().map(record => record.toHex())) // publicKeyArmored's private key
console.log('message.getFilename', message.getFilename()) // null
console.log('message.getLiteralData', message.getLiteralData()) // null
console.log('message.getSigningKeyIDs', message.getSigningKeyIDs()) // [] but it should have privateKeyArmored's public key or private key?
console.log('message.getText', message.getText()) // null The readMessage's getSigningKeyIDs() is an empty array despite the original message was being encrypted with a signing key. The only way to get the signing keys is to decrypt the message. Was this intentional? |
Beta Was this translation helpful? Give feedback.
Answered by
larabr
Dec 31, 2021
Replies: 1 comment
-
Hi @Joakal , the signed data is encrypted. So you need to decrypt the message, to be able to access the signature. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Joakal
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @Joakal , the signed data is encrypted. So you need to decrypt the message, to be able to access the signature.