fix(ui): migrate signing key to delegate on identity import#186
Merged
Conversation
After importing an identity, the chat delegate may have a stale signing
key for the room from a prior session. When the user tries to send a
message, the delegate signs with the old key, producing signatures that
the contract rejects ("State verification failed: Invalid signature").
The fix migrates the imported signing key to the delegate immediately
during the import flow, before any message sends can occur. This uses
migrate_signing_key() which handles the stale key case by overwriting
any existing key and then sanitizing messages with invalid signatures.
Closes #185
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests three cases: message with wrong signature removed while valid messages kept, unknown author removed, and empty messages list handled. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Match the pattern in get_response.rs: track whether remove_unverifiable_messages actually removed anything, and call mark_needs_sync to persist the cleaned state to the delegate. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Problem
After importing an identity token, sending messages fails with "State verification failed: Invalid signature" (report 7Y3PM6, issue #185). The chat delegate may have a stale signing key for the room from a prior session. When the user sends a message,
sign_message_with_fallback()asks the delegate to sign first — the delegate uses the old key, producing signatures the contract rejects.This affected ALL imports, including tokens exported from the same node on the same version.
Approach
Migrate the imported signing key to the delegate immediately during the import flow, before any message sends can occur. Uses
migrate_signing_key()which:AlreadyCurrent)StaleKeyOverwritten)Stored)After successful migration, also runs
remove_unverifiable_messages()to sanitize any messages in local state that may have been signed with the old key.Testing
cargo make test)Closes #185
[AI-assisted - Claude]