-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PreKey is being removed after the first message encryption #74
Comments
Hi @gediminasiv and apologies for the slow response on your comment on the other repo. At first glance this does look like a bug in the SDK, not in the demo. The pre-key needs to be removed, but should not be removed until the session is established by both parties. I will confirm and see if we can delay pre-key removal in the SDK and add a test case based on your scenario. If you have a specific proposal for when the pre-key should be removed, let me know or create a PR. In the meantime you could work around this at a higher layer by having your application immediately return an ACK or "read receipt" message after receiving that first type 3 message. That way there will be an encrypted response to the first message whether or not User B replies. There will still be failed delivery risks, so it isn't perfect, but messaging failure seems far less likely than a non-responsive user :) |
Hi, Rolfe! No worries about the slow response over there. I figured that you might not be checking the samples repository as often, so created an issue here :) As far as I understand, till you release a fix, we will need to manually check whether the session is already established by two parties or not. Maybe do you have any suggestions on how we should do it? :) |
After thinking about this a little I think the problem is that we shouldn't be reusing that one-time prekey. I won't have a chance to look into it until this weekend, but I will try to put together a definitive answer then - either an SDK fix or usage examples. In the meantime, I would see if you can:
I think the first one, or something close to it, is the real solution but I haven't been working inside this code for a while so I must answer hesitantly :) |
Hi @gediminasiv! I finally looked at this carefully and here is my understanding of the situation:
To verify this I have added some simple tests: https://github.com/privacyresearchgroup/libsignal-protocol-typescript/blob/master/src/__test__/session-builder.test.ts#L55 So... it seems I do not quite understand the problem you are facing. Do you think you can give me a more detailed code example? Or better yet a PR with a failing test case? Thanks, and sorry I couldn't come back with an easy answer :) |
Hey, @rolfeschmidt ! Thank you so much for investigating this in such detail. Unfortunately I cannot attach the full repo as I am under an NDA in my company, but your answer suggests that I might be missing something here, so I will try to provide you with the bits that might be needed :D Here is my message decryption code, from the frontend side:
Parameters are as follows: It is worth mentioning that this function is called in a fashion similar to Anyway, when I receive several prekey messages and try to read them with this code, it decrypts first prekey message successfully, and when it tries to decrypt the second one I get an error from |
Hi @gediminasiv - I haven't figured out what is going on here so haven't updated. My concern is with the storage of the Here is where I would be looking:
I would use the tools at my disposal - debugger, console logs, etc - to confirm that the session is in fact getting stored correctly, that the I'll keep thinking about this and trying to find test cases. Can you confirm two things for me:
I know I'm sending you deeper into the guts of this than we'd like, but I'm stumped. |
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:
┆Issue is synchronized with this Asana task
The text was updated successfully, but these errors were encountered: