tiabc / doubleratchet

The Double Ratchet Algorithm implementation in Go
MIT License
5 stars 3 forks source link

State management #2

Open cammellos opened 6 years ago

cammellos commented 6 years ago

Hi! Thanks for the library, I am integrating https://github.com/status-im/doubleratchet with the status application, I have a few questions and I was hoping you could confirm some doubts.

The application is a mobile app, so it will need persistence on disk. I have implemented keysstorage, but seems like to get it working correctly we need also to persist and reload state when a new struct is created, otherwise key re-use happens.

Essentially when the process is restarted, we have to create a new session, but we don't want N and PN to be set back to 0, as we have already performed some steps in the ratchet.

I had a look at the signal implementation and seems like they are also persisting session state https://github.com/signalapp/libsignal-protocol-java/blob/master/java/src/main/java/org/whispersystems/libsignal/state/SessionRecord.java.

Could you confirm if I am on the right track before I start coding away or I am missing something?

Thank you!

tiabc commented 6 years ago

Hi! Yes, you'll have to persist state between reload, I believe you're on the right track. Currently, the key storage was developed this way for the sake of simplicity and it should be fixed for real production use.