Repository navigation
fix(xchat): wrap the newest identity version in the conversation-key handshake - #220
Merged
Merged
Conversation
…handshake
GET /2/users/{id}/public_keys returns every identity an account has ever
registered, oldest first. `_initiate_conversation` used records[0], so once a
participant had registered a second identity - the X app re-initialising
encrypted DMs, or an identity registered by another client - the handshake
kept wrapping a superseded key and X refused it:
HTTP 400 Invalid identity key: one or more participant keys do not use the
latest public key version.
Conversation keys then never seed, and a client that cannot establish
encryption falls back to unencrypted DMs, which this adapter does not read.
Select the numerically greatest public_key_version instead. Versions are
millisecond timestamps whose string length can vary, so compare them as
integers, per the X Chat troubleshooting guide.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_initiate_conversationselected a participant's identity withrecords[0], the first record returned byGET /2/users/{id}/public_keys— the oldest identity the account ever registered. X refuses a conversation key built on anything but the account's latest version, so any recipient that had registered a second identity could never be messaged:This selects the numerically greatest
public_key_versioninstead. They are millisecond timestamps whose string length can vary, so the comparison is done as integers — the caution the X Chat troubleshooting guide gives for exactly this comparison.Reproduction
Against a recipient whose account had three registered identities (oldest first):
hermes send -t xchat:<id> "…"failed every time with the 400 above, whilehermes xchat statusreported every credential green. Because the conversation key never seeds, the recipient's client falls back to an unencrypted thread — which this adapter does not read — so the user-visible symptom is silence rather than an error.Single-identity accounts are unaffected, which is why the defect hides until an account rotates or re-initialises its keys.
Tests
xchat/tests/on this branch: 56 passed.The new test,
test_handshake_wraps_the_newest_identity_version, fails on the unpatched base — the control that shows the old rule was the broken one:Related
_register_signing_keys.Closes #219.