react-native-virgil-crypto
react-native-virgil-crypto copied to clipboard
Error: Recipient defined with id is not found within message info during data decryption.
Hey Team,
We're noticing a small fraction of our users getting this error. These users will always get the following error. The vast majority of our users do not experience this.
Recipient defined with id is not found within message info during data decryption.
We haven't been able to replicate this issue. We use this library to decrypt an encrypted private api key (for a third party integration) sent over the air to the user's device.
Specifically, we first call
const keys = virgilCrypto.generateKeys('SECP256R1');
privateKey = virgilCrypto.exportPrivateKey(keys.privateKey).toString('base64');
publicKey = virgilCrypto.exportPublicKey(keys.publicKey).toString('base64');
then we send the public key up to our api endpoint that's using the nodejs virgil-crypto package and encrypt our api key
import { initCrypto, VirgilCrypto, KeyPairType } from 'virgil-crypto';
// ...
await initCrypto();
const virgilCrypto = new VirgilCrypto({
/** cSpell:ignore secp */
defaultKeyPairType: KeyPairType.SECP256R1,
});
return virgilCrypto.encrypt(
Buffer.from([REDACTED]),
virgilCrypto.importPublicKey(publicKey),
).toString('base64');
back on the device, we decrypt it as follows. The error gets thrown somewhere here
const key = virgilCrypto.decrypt(encryptedMessage, virgilCrypto.importPrivateKey(privateKey)).toString()
I had tried a retry method that performs this entire sequence again if any error occurred, but this doesn't help the users suffering from this specific issue. What can I do to help this project with resolving this sort of issue?
The only way we could reproduce it is for you to provide a sample key and data set that reproduces the issue:
- A private key that cannot decrypt the data (create a random one that reproduces the issue)
- Encrypted data for the corresponding public key