Skip to content
This repository was archived by the owner on Mar 10, 2026. It is now read-only.

Commit 8abcd2b

Browse files
committed
fix: PFS not rotating
1 parent e125fb1 commit 8abcd2b

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

logic/message.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,25 +122,25 @@ def send_message_processor(user_data, user_data_lock, contact_id: str, message:
122122
rotate_at = user_data["contacts"][contact_id]["ephemeral_keys"]["rotate_at"]
123123

124124

125-
# If we have keys, but no one-time-pads, we send new pads to the contact
126-
if not our_pads:
127-
logger.debug("We have no pads to send message")
125+
# We rotate keys before generating and sending new batch of pads because
126+
# ephemeral key exchanges always get processed before messages do.
127+
# Which means if we generate and send pads with contact's, we would be using his old key, which would get overriden by the request, even if we send pads first
128+
# This is because of our server archiecture which prioritizes PFS requests before messages.
129+
#
130+
# Another note, that means after batch ends, and rotation time comes, you won't be able to send messages until other contact is online.
131+
# This will (hopefully) change in a future update
132+
if rotation_counter == rotate_at:
133+
logger.info("We are rotating our ephemeral keys for contact (%s)", contact_id)
134+
ui_queue.put({"type": "showinfo", "title": "Perfect Forward Secrecy", "message": f"We are rotating our ephemeral keys for contact ({contact_id[:32]})"})
135+
send_new_ephemeral_keys(user_data, user_data_lock, contact_id, ui_queue)
128136

137+
save_account_data(user_data, user_data_lock)
138+
return False
129139

130-
# We rotate keys before generating and sending new batch of pads because
131-
# ephemeral key exchanges always get processed before messages do.
132-
# Which means if we generate and send pads with contact's, we would be using his old key, which would get overriden by the request, even if we send pads first
133-
# This is because of our server archiecture which prioritizes PFS requests before messages.
134-
#
135-
# Another note, that means after batch ends, and rotation time comes, you won't be able to send messages until other contact is online.
136-
# This will change in a future update
137-
if rotation_counter == rotate_at:
138-
logger.info("We are rotating our ephemeral keys for contact (%s)", contact_id)
139-
ui_queue.put({"type": "showinfo", "title": "Perfect Forward Secrecy", "message": f"We are rotating our ephemeral keys for contact ({contact_id[:32]})"})
140-
send_new_ephemeral_keys(user_data, user_data_lock, contact_id, ui_queue)
141140

142-
save_account_data(user_data, user_data_lock)
143-
return False
141+
# If we have keys, but no one-time-pads, we send new pads to the contact
142+
if not our_pads:
143+
logger.debug("We have no pads to send message")
144144

145145
if not generate_and_send_pads(user_data, user_data_lock, contact_id, ui_queue):
146146
return False

0 commit comments

Comments
 (0)