Repository navigation
fix(xchat): a KeyChange refreshes its sender's public-key roster - #191
salch-cred wants to merge 2 commits into
Conversation
|
Independent reproduction of #173 from a live install, in case it strengthens #191. Setup: Five events, all of them, with no recovery over several minutes — consistent with Scope note, and no overlap intended: this PR touches So a recipient with more than one registered identity cannot be messaged at all — the conversation key never seeds, and their client falls back to an unencrypted thread, which this adapter does not read. I have a separate issue and patch staged for that rather than widening this one. |
A second device enabling X Chat encryption registers a new identity and rotates the conversation key; the KeyChange is signed with that new version's signing key. Signing keys were only fetched for senders not already known, so the new version never entered the XDK roster, every KeyChange failed verification ("no matching signing key"), no conversation key was extracted, and all later messages stayed undecryptable until restart (NousResearch#173).
Decrypt the KeyChange blobs for their sender ids and fetch those senders unconditionally, deduplicating the roster by (user, version) so repeats do not grow it.
4e64b8d to
1b8347a
Compare
|
Rebased onto main ( |
|
Confirmed against the current head of main, not just the PR's rebase base.
No overlap with #220 either. That PR (merged 6 Nov, Live-install evidence for the inbound failure is in my earlier comment above: three identity versions on the counterparty, every inbound event failing verification, and decryption restored immediately by a restart that cleared On the test counts: I could not reproduce the 12 failures on either ref, so naming them would not help a reviewer. Under the workflow's own conditions — hermes-agent checkout on |
KeyChange blobs are Thrift-encoded (checked against chatxdk 0.4.1's prepare_conversation_key_change output), so json.loads(b64decode(blob)) never yields a sender_id and the refresh set was always empty in production; the tests only passed because they fed JSON blobs. Refresh the conversation's participants (both ids of a 1:1, the page's senders, and the account itself) once per KeyChange blob not seen before.
|
Thank you @salch-cred! This landed on main through #446, which stacked the 34 reviewed official-plugin PRs on current main so their shared files (CHANGELOGs, versions, the README grid) conflicted only once. Your commits are kept with your authorship; this PR's tip is 594b485. To get it now: |
fix(xchat): a KeyChange refreshes its sender's public-key roster
Root cause
Signing keys are fetched only for unknown senders (
senders -= self._known_senders), and_register_signing_keysis only given the page's messages. When another device enables X Chat encryption it registers a second identity and signs the resultingKeyChangewith the new version's signing key ? but the sender is already known, so that key never reaches the XDK roster. The SDK rejects the change withno matching signing key, no conversation key is extracted, and every following message fails withno matching key founduntil restart.Fix
KeyChangeblob for itssender_id(_key_event_senders, best-effort) and refresh exactly those senders regardless of_known_senders; keys are still fetched for all message senders as before.(user_id, public_key_version), so repeated key changes do not grow it, and keep pushing the full roster because the SDK store is replaced wholesale.Tests
tests/test_xchat_adapter.py:test_a_keychange_refreshes_a_known_senders_roster: sender known with v3, phone registers v4 and sends a KeyChange ? roster becomes {3, 4}. Red on main (24d49a4: roster stays {3}), green here.test_the_roster_does_not_grow_on_repeat_keychanges: two polls, one version ? still one entry. Red on main only because the refresh never happens.test_xchat_adapter.py+test_xchat_api.py: 53 passed.Draft: the reporter's live X account cannot be driven from this host; the offline fakes exercise the adapter path, and the SDK-level ordering the issue describes (
set_signing_keysbeforedecrypt_events) is pinned by the existing batch test.Closes #173.