fix(passkey): Wrap passkey private key under parent login's item key#50
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the credentials passkey flows to (1) encrypt/decrypt passkey private keys using the parent login’s item key (instead of a dedicated passkey encryption key) and (2) introduce a small session-auth state machine to drive biometric-first unlock with password fallback (including improved biometric error handling).
Changes:
- Wrap passkey private keys under the parent login’s item key during creation, and unwrap them similarly during provide/authentication.
- Introduce
SessionAuthState+mapUnlockErrorand update Create/Provide credential activities to handle biometric unlock + password fallback viafeature:auth. - Add/extend testFixtures (fake passkey manager/repository, biometric availability/controller/session) and unit tests for the new auth-state behavior.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| rust/src/testFixtures/kotlin/de/davis/keygo/rust/FakePasskeyManager.kt | Adds a RustPasskeyInterface fake for JVM tests. |
| feature/credentials/src/test/kotlin/de/davis/keygo/feature/credentials/presentation/provide/activity/ProvidePasskeyViewModelTest.kt | Adds unit tests for Provide flow session-auth state transitions. |
| feature/credentials/src/test/kotlin/de/davis/keygo/feature/credentials/presentation/create/activity/CreatePasskeyViewModelTest.kt | Adds unit tests for Create flow session-auth state transitions. |
| feature/credentials/src/main/kotlin/de/davis/keygo/feature/credentials/presentation/provide/activity/ProvidePasskeyViewModel.kt | Decrypts passkey private key using parent login’s item key; adds auth state + unlock handling. |
| feature/credentials/src/main/kotlin/de/davis/keygo/feature/credentials/presentation/provide/activity/ProvidePasskeyActivity.kt | Uses session-auth state to drive biometric unlock then password fallback via auth graph. |
| feature/credentials/src/main/kotlin/de/davis/keygo/feature/credentials/presentation/provide/activity/DecryptPasskeyEncryptionKeyRequest.kt | Removes old passkey-encryption-key biometric request model. |
| feature/credentials/src/main/kotlin/de/davis/keygo/feature/credentials/presentation/create/activity/CreatePasskeyViewModel.kt | Encrypts passkey private key using parent login’s item key; adds auth state + unlock handling. |
| feature/credentials/src/main/kotlin/de/davis/keygo/feature/credentials/presentation/create/activity/CreatePasskeyBiometricRequestEvent.kt | Removes old create-flow biometric request event model. |
| feature/credentials/src/main/kotlin/de/davis/keygo/feature/credentials/presentation/create/activity/CreatePasskeyActivity.kt | Adds biometric unlock + password fallback gating before showing authenticated flow NavHost. |
| feature/credentials/src/main/kotlin/de/davis/keygo/feature/credentials/presentation/auth/SessionAuthState.kt | Adds session auth state + mapping from unlock errors to UI outcomes. |
| feature/credentials/build.gradle.kts | Enables returnDefaultValues for unit tests; adds dependencies + testFixtures deps. |
| core/security/src/testFixtures/kotlin/de/davis/keygo/core/security/crypto/FakeSession.kt | Tracks whether a session was started in tests. |
| core/security/src/testFixtures/kotlin/de/davis/keygo/core/security/crypto/FakeBiometricCryptoController.kt | Adds a biometric controller fake for unwrap tests. |
| core/security/src/testFixtures/kotlin/de/davis/keygo/core/security/crypto/FakeBiometricAvailabilityRepository.kt | Adds a fake biometric availability repository for unit tests. |
| core/security/src/main/kotlin/de/davis/keygo/core/security/domain/model/KeyId.kt | Removes the old PasskeyEncryptionKey constant. |
| core/item/src/testFixtures/kotlin/de/davis/keygo/core/item/FakePasskeyRepository.kt | Adds an in-memory PasskeyRepository fake for tests. |
| core/item/src/main/kotlin/de/davis/keygo/core/item/domain/model/Passkey.kt | Adds a shared label constant for encrypt/decrypt of passkey private key. |
| core/identity/src/test/kotlin/de/davis/keygo/core/identity/presentation/BiometricUnlockAdapterImplTest.kt | Adds tests verifying biometric unlock adapter error mapping and session start. |
| core/identity/src/main/kotlin/de/davis/keygo/core/identity/presentation/BiometricUnlockAdapterImpl.kt | Changes unwrap failure mapping to return BiometricFailed with underlying error. |
| core/identity/src/main/kotlin/de/davis/keygo/core/identity/domain/model/UnlockError.kt | Adds BiometricFailed error variant. |
| core/identity/build.gradle.kts | Adds core.security testFixtures dependency for new tests. |
| CLAUDE.md | Updates documented testing guidance (prefer fakes/testFixtures; avoid mocks by default). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… key Implements issue #45: passkey private keys are now encrypted under the parent Login's item key (AAD = passkey_private_key) instead of a central keystore biometric key. Adds the brainstormed design spec and the implementation plan for the follow-up transparent-biometric UX work. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Mirrors the ProvidePasskeyViewModel auth pattern: transparent biometric attempt on init, fallback to password via NeedsPassword state, and onUnlocked/onUnlockFailed callbacks. Updates CreatePasskeyActivity to use the new state-driven auth flow. Adds unitTests.isReturnDefaultValues to enable Log.w stubs in JVM tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
4009518 to
35cb99e
Compare
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.
Wraps passkey private keys under parent login's item key and implements SessionAuthState for credentials flow with proper biometric error handling.