I'm using libsignal-protocol-java according to Signal's Documentation to implement end-to-end encryption in a messaging app.
Let's say Alice sends Bob a (pairwise) serialized ciphertext message. How does Bob know how to deserialize it? Doesn't he first need to know the type of the ciphertext message? My understanding is that a pairwise ciphertext message could either be a signal message (WHISPER_TYPE
) or a pre key signal message (PREKEY_TYPE
). So how does Bob know which type it is?
Is Alice supposed to also send Bob the type (as plaintext) of the ciphertext message?
Or is there another way that Bob could detect the type? For example, is Bob supposed to try to deserialize it as if it's a signal message, and if that fails, then try to deserialize it as if it's a pre key signal message?
1 - Alice generate identityKeyPair(Long Term), signedPreKey(Medium Term) & Ephemeral PreKeys & save those keys into storage in base64. e.g
2 - Send
For Encryption and Decryption you first have to make to encrypted session
Encryption & Decryption
You can also look other source code which are available on github https://github.com/lvijay/DemoSignal
https://github.com/signalapp/libsignal-protocol-java/pull/21/commits/3496ed996359f6d3d8ee52dcecb8f8b0d45b3cbc (The Library author is using is wrapper of signal protocol you can change wrapper library to signal protocol)