Skip to content

fix: overwrite stale delegate signing key after re-invitation#169

Merged
sanity merged 1 commit intomainfrom
fix-delegate-signing
Mar 13, 2026
Merged

fix: overwrite stale delegate signing key after re-invitation#169
sanity merged 1 commit intomainfrom
fix-delegate-signing

Conversation

@sanity
Copy link
Contributor

@sanity sanity commented Mar 13, 2026

Problem

After PR #164 (delegate signing API change), all users were re-invited. The re-invitation updates the user's self_sk (signing key) in the UI, but the chat delegate retains the old signing key.

migrate_signing_key() detects the mismatch at startup but returns false instead of overwriting the stale key. Since sign_message_with_fallback() tries the delegate first and the delegate "succeeds" (signs with the wrong key), the fallback (correct key) is never reached. Every message signed this way fails signature verification on all peers — creating a one-way split brain where the sender sees their own messages (optimistic local state) but nobody else does.

Approach

Change the key-mismatch branch in migrate_signing_key() from early-return to fall-through, so it reaches the existing store_signing_key + verify path. This overwrites the stale delegate key with the current one. The fix is 3 lines in ui/src/signing.rs.

No delegate WASM changes — only UI-side logic, so no delegate migration needed.

Testing

  • Verified cargo check -p river-ui --target wasm32-unknown-unknown --features no-sync passes
  • The fix was diagnosed from production logs showing State verification failed: Invalid message signature on Ian's node starting at 06:04 UTC March 13, correlated with the delegate warning Delegate has different key for room

[AI-assisted - Claude]

When a user is re-invited to a room, the delegate retains the old signing
key. migrate_signing_key() detected the mismatch but returned false instead
of overwriting, leaving the stale key in place. Since sign_message_with_fallback()
tries the delegate first and the delegate "succeeds" (with the wrong key),
messages fail signature verification on all peers.

Fix: fall through to the store_signing_key path when a key mismatch is
detected, overwriting the stale key with the current one.

Closes #165

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sanity sanity merged commit 66817d9 into main Mar 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant