feat(keys): add SeedPhraseKey.load() and CryptoProviderKey identifier storage#83
Conversation
… storage
- SeedPhraseKey: add static Companion.load(id, password, storage) factory
method that decrypts and reconstructs a SeedPhraseKey without requiring
an existing instance, enabling key recovery independent of Account cache
- CryptoProviderKey: add companion object with three static helpers for
persisting an opaque provider identifier (e.g. Android Keystore prefix)
independently of the Account cache:
saveProviderIdentifier(id, identifier, password, storage)
getProviderIdentifier(id, password, storage): String?
hasProviderIdentifier(id, storage): Boolean
Identifier is encrypted with ChaCha20-Poly1305 via ChaChaPolyCipher.
Removes AndroidKeystoreKey (superseded by CryptoProviderKey companion).
- settings.gradle: bump Android Gradle Plugin to 8.8.2
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PR SummaryEnhanced the keys module with static factory methods for key recovery independent of account cache. Added Changes
autogenerated by presubmit.ai |
There was a problem hiding this comment.
✅ LGTM!
Review Summary
Commits Considered (1)
-
4e8c186: feat(keys): add SeedPhraseKey.load() and CryptoProviderKey identifier storage
-
SeedPhraseKey: add static Companion.load(id, password, storage) factory
method that decrypts and reconstructs a SeedPhraseKey without requiring
an existing instance, enabling key recovery independent of Account cache -
CryptoProviderKey: add companion object with three static helpers for
persisting an opaque provider identifier (e.g. Android Keystore prefix)
independently of the Account cache:
saveProviderIdentifier(id, identifier, password, storage)
getProviderIdentifier(id, password, storage): String?
hasProviderIdentifier(id, storage): Boolean
Identifier is encrypted with ChaCha20-Poly1305 via ChaChaPolyCipher.
Removes AndroidKeystoreKey (superseded by CryptoProviderKey companion). -
settings.gradle: bump Android Gradle Plugin to 8.8.2
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
Files Processed (3)
- Android/wallet/settings.gradle (1 hunk)
- Android/wallet/src/main/java/com/flow/wallet/keys/CryptoProviderKey.kt (2 hunks)
- Android/wallet/src/main/java/com/flow/wallet/keys/SeedPhraseKey.kt (1 hunk)
Actionable Comments (0)
Skipped Comments (5)
-
Android/wallet/src/main/java/com/flow/wallet/keys/CryptoProviderKey.kt [138-138]
security: "Password should be processed through a key derivation function."
-
Android/wallet/src/main/java/com/flow/wallet/keys/CryptoProviderKey.kt [156-156]
security: "Password should be processed through a key derivation function."
-
Android/wallet/src/main/java/com/flow/wallet/keys/SeedPhraseKey.kt [72-72]
security: "Password should be processed through a key derivation function."
-
Android/wallet/src/main/java/com/flow/wallet/keys/CryptoProviderKey.kt [157-158]
maintainability: "Exception handling could benefit from logging for debugging."
-
Android/wallet/src/main/java/com/flow/wallet/keys/SeedPhraseKey.kt [76-77]
maintainability: "Exception handling could benefit from logging for debugging."
Overview
This PR introduces two additions to the
keysmodule that decouple key material from theAccountobject, enabling key recovery even after an account-cache loss.Changes
1.
SeedPhraseKey— staticload()factoryCompanion.load(id, password, storage)decrypts and reconstructs aSeedPhraseKeydirectly from aStorageProtocolwithout needing an existing instance. Returnsnullon miss or decryption failure (never throws).2.
CryptoProviderKey— companion identifier storage helpersThree static methods for persisting an opaque provider identifier (e.g. an Android Keystore alias, key prefix, slot number) independently of the account cache:
saveProviderIdentifier(id, identifier, password, storage)getProviderIdentifier(id, password, storage): String?nullon miss or errorhasProviderIdentifier(id, storage): BooleanTypical lifecycle (Android Keystore example):
The same pattern works for any future
CryptoProviderimplementation (Ledger, HSM, custom signers, etc.).3.
AndroidKeystoreKey— removedAndroidKeystoreKeywas aKeyProtocolsubclass whose only consumed functionality was three static storage helpers. Those helpers are now provided byCryptoProviderKey.companion, making the class redundant. All call sites updated to useCryptoProviderKey.saveProviderIdentifier / getProviderIdentifier / hasProviderIdentifier.4.
settings.gradle— AGP bumpAndroid Gradle Plugin
8.6.1→8.8.2.Test Plan
SeedPhraseKey.load()returns a valid reconstructed key afterstore()SeedPhraseKey.load()returnsnullfor an unknown idCryptoProviderKey.getProviderIdentifier()returns the original string aftersaveProviderIdentifier()CryptoProviderKey.hasProviderIdentifier()returnsfalsebefore save,trueafternull(no exception propagated)AndroidKeystoreKeyremain in any call site🤖 Generated with Claude Code