You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to implement your protocol to our own application and encountered an unexpected problem.
Lets imagine a standard situation. User A sends message to User B. Operation is standard - User A encrypts a message using User B prekeys, and then User B downloads that message from server, decrypts it with his prekeys.
The problem occurs when User B doesn't reply to User A message, and User A sends another message. Message type is still 3, so it has to be decrypted with decryptPreKeyWhisperMessage. Problem is that after first decryption of prekey message, local prekey of User B is deleted, so it cannot do any more decryption for User A messages.
If I leave removePreKey function in my storage class empty, everything works just fine.
The code is pretty basic, taken from your samples:
try {
if (message.type === 1) {
plaintext = await cipher.decryptWhisperMessage(message.body!, "binary");
} else if (message.type === 3) {
plaintext = await cipher.decryptPreKeyWhisperMessage(
message.body!,
"binary"
);
}
stringPlaintext = new TextDecoder().decode(new Uint8Array(plaintext));
} catch (e) {
console.log(
`Decrypting unsuccessful. Message shouldn't be saved to server.`
);
throw e;
}
Is this a bug, or am I missing something out?
The text was updated successfully, but these errors were encountered:
gediminasiv
changed the title
PreKey is being removed after the first message encryption
PreKey is being removed after the first message decryption
Mar 15, 2022
Hello!
I am trying to implement your protocol to our own application and encountered an unexpected problem.
Lets imagine a standard situation. User A sends message to User B. Operation is standard - User A encrypts a message using User B prekeys, and then User B downloads that message from server, decrypts it with his prekeys.
The problem occurs when User B doesn't reply to User A message, and User A sends another message. Message
type
is still 3, so it has to be decrypted withdecryptPreKeyWhisperMessage
. Problem is that after first decryption of prekey message, local prekey of User B is deleted, so it cannot do any more decryption for User A messages.If I leave
removePreKey
function in my storage class empty, everything works just fine.The code is pretty basic, taken from your samples:
Is this a bug, or am I missing something out?
The text was updated successfully, but these errors were encountered: