joebandenburg / libaxolotl-javascript

A JavaScript implementation of axolotl. Axolotl is a ratcheting forward secrecy protocol.
GNU Lesser General Public License v3.0
75 stars 13 forks source link

Serializing Session object #10

Closed tvandergeer closed 8 years ago

tvandergeer commented 9 years ago

Hello Joe,

I've been working on integrating end-to-end encryption in our node-whatsapi project. I'm using your implementation of axolotl and this works great! I'm at the point that it's able to send encrypted messages that can be decrypted by an official WhatsApp client (App). So far so good.

As part of the implementation I've created a Keystore as required by the javascript-axolotl lib. We're using SQLite for persisting the data. In order to do this I have to serialize some objects (KeyPairs, Session, etc). Currently I'm looking into the best way of serializing the Session object to be able to store (and recorver) from SQLite. I hoped that I could use the protobuf definition for LocalStorageProtocols as supplied in the TexSecure code (just like you did with the WhisperTextProtocols), but the Session object in javascript-axolotl seems to differ from the protobuf definition. Is this intentionally?

Do you have any pointers on how you would proceed with serializing the Session object?

Best regards,

Tom van der Geer

tvandergeer commented 9 years ago

I've managed to serialize the Session object by creating my own .proto definition that resembles the Session object from libaxolotl-javascript. The Session object is now correctly serialized and deserialized.

NB. I had to fix the ArrayBuffer type that was lost in de serialization/deserialization process, but that was fairly easy by using the traverse module.

tvandergeer commented 9 years ago

I've committed the code here

joebandenburg commented 8 years ago

Hi Tom,

Great to hear you solved your problem by using protobufs to serialise the session state. To answer your initial question, it was never my intention to be compatible with how the Java library stored its state, although I could see how that might be useful if one wanted to share session state between implementations.

Do you think that libaxolotl should do the serialisation/deserialisation of the session state itself so the user only needs to store a binary blob?