Skip to content

Conversation

@lmuntaner
Copy link
Contributor

@lmuntaner lmuntaner commented Oct 31, 2025

Motivation

Enable users to recover access to their identities using the recovery phrase.

In this PR, I set up the flow until the recovery phrase enables an authenticated connection with the backed, effectively restoring access.

NOT IN THIS PR:

  • Final success message.
  • User experience on errors.

Changes

  • Copied the recovery helpers and tests from the iiConnection and legacy directory.
  • Added a new flow recoverWithPhraseFlow.svelte.ts to encapsulate the recovery logic, including phrase validation, device lookup, and authentication.
  • Introduced isValidMnemonic and enforced mnemonic validation in fromMnemonic (previously fromMnemonicWithoutValidation), throwing an error for invalid mnemonics.
  • Refactored the recovery phrase input UI to use a reactive array of word objects, added support for pasting multiple words, auto-focusing, and auto-submitting when all words are filled.

Tests

Tested locally:

  • Inserting all words manually.
  • Copy pasting all words.

@lmuntaner
Copy link
Contributor Author

New UX:

Copy pasting all the words

Screen.Recording.2025-10-31.at.10.04.18.mov

Invalid mnemonic

Screen.Recording.2025-10-31.at.10.05.46.mov

Manually adding last word

Screen.Recording.2025-10-31.at.10.05.58.mov

@lmuntaner lmuntaner requested a review from Copilot November 3, 2025 08:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a recovery phrase input UI and the underlying flow to recover an identity using a 24-word BIP-39 mnemonic phrase. The implementation includes SLIP-0010 key derivation, mnemonic validation, and authentication logic.

  • Adds a recovery phrase input form with 24 word fields supporting keyboard navigation and paste functionality
  • Implements SLIP-0010 Ed25519 key derivation from BIP-39 mnemonics with proper hardened path support
  • Creates a recovery flow that validates the mnemonic, derives the identity, and authenticates against the canister

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
src/frontend/src/routes/(new-styling)/recovery-phrase/+page.svelte Implements the recovery phrase UI with 24 input fields, keyboard navigation, paste handling, and auto-submit on completion
src/frontend/src/lib/utils/recoveryPhrase.ts Provides SLIP-0010 key derivation utilities, BIP-39 mnemonic validation, and Ed25519 identity generation from mnemonics
src/frontend/src/lib/utils/recoveryPhrase.test.ts Tests SLIP-0010 derivation against official test vectors and validates behavior with invalid mnemonics
src/frontend/src/lib/flows/recoverWithPhraseFlow.svelte.ts Orchestrates the recovery flow including mnemonic validation, identity derivation, and authentication with the canister

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lmuntaner lmuntaner marked this pull request as ready for review November 3, 2025 09:34
@lmuntaner lmuntaner requested a review from sea-snake November 3, 2025 09:34
words: string[],
): Promise<
| { success: true; info: IdentityInfo; identity: DelegationIdentity }
| { success: false; error: Error }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just throw the error?

Copy link
Contributor

@sea-snake sea-snake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lmuntaner lmuntaner added this pull request to the merge queue Nov 3, 2025
github-merge-queue bot pushed a commit that referenced this pull request Nov 3, 2025
* Recovery flow happy path

* Refactor to a function

* Support pasting words

* Use global agent options and submit on enter or word pasting

* Revert and improve comments

* Remove unnecessary comment and unused import

* Remove unnecessary import

* GH review changes

* Change submit trigger

* Refactor to throw instead of variant
Merged via the queue into main with commit 21c422c Nov 3, 2025
75 checks passed
@lmuntaner lmuntaner deleted the lm-recovery-phrase-happy-path branch November 3, 2025 11:34
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.

2 participants