({message, keyring, encryptionKeyIds, unlockKey, format})
| 19 | * @return {Object} |
| 20 | */ |
| 21 | export async function decrypt({message, keyring, encryptionKeyIds, unlockKey, format}) { |
| 22 | let privateKey = keyring.getPrivateKeyByIds(encryptionKeyIds); |
| 23 | privateKey = await unlockKey({key: privateKey}); |
| 24 | const verificationKeys = keyring.keystore.getAllKeys(); |
| 25 | const result = await pgpDecrypt({message, decryptionKeys: privateKey, verificationKeys, format}); |
| 26 | result.signatures = await mapSignatures(result.signatures, keyring); |
| 27 | if (format === 'binary') { |
| 28 | result.data = Uint8Array2str(result.data); |
| 29 | } |
| 30 | return result; |
| 31 | } |
| 32 | |
| 33 | async function mapSignatures(signatures, keyring) { |
| 34 | return Promise.all(signatures.map(async signature => { |
nothing calls this directly
no test coverage detected