mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.8 KiB
2.8 KiB
Loki Session Reset
Signal
Since Signal uses a centralised server, creating sessions is easy as the prekeys can be easily fetched.
The process is as follows:
Adeletes all their sessions and sendsEnd SessiontoBAcontacts the server and creates a new session
BGets this message and deletes all sessions.BSends a message with a newly created sessionBcontacted server and established this
AandBnow have the same sessions so they can delete any archived ones.
Loki
Loki doesn't have a centralised server and thus we need to change the process above with something similar.
We have to introduce a session reset state sessionState which can take the following states:
none: No session reset is in progressinitiated: We have initiated the session resetreceived: We have received a session reset from the other user
The new process is as follows:
ASendsEnd Sessionwith aPreKeyBundleand archives its own session.sessionState = initiated- The session is archived as we could get a message from
Busing the archived session, so we still want to be able to decrypt that. - We can show
Session reset in progress
BGets this message and saves thePreKeyBundleand archives its own sessions.sessionState = receivedBsends an empty message, which will trigger a new session to be created.Bdeletes thePreKeyBundleonce session is created.- We can show
Session reset in progress
AandBboth do the routine below when receiving messages.
Upon receiving message (Only applies to PreKey and Cipher messages)
- Store the current active session
PS - Decrypt the message
- Decrypting a message can cause the active session to change
- If
sessionState == nonethen it means that we haven't started session reset and we can abort. - Get the current session
CS - If
PSisnilthen abort as we didn't have a session before. - If
CS != PSthen sessions were changed.- If
sessionState == receivedthen it means that the sender used an old session to contact us. We need to wait for them to use the new one.- Archive
CSand set the session toPS
- Archive
- If
sessionState == initiatedthen it means that the sender acknowledged our session reset and sent a message with a new session- Delete all session except
CS sessionState = none- Send an empty message to confirm session adoption
- We can show
Session reset done
- Delete all session except
- If
- If
CS == PSthen sessions were the same.- If
sessionState == receivedthen it means that the new session we created is the one the sender used for sending message. We have successfully adopted the new session. - Delete all sessions except
PS sessionState = none- We can show
Session reset done
- If