zcash-swift-wallet-sdk
zcash-swift-wallet-sdk copied to clipboard
Fail Fast on Key Mismatch During Initialization
What is your feature request? When the SDK is initialized, it should fail fast if the viewing keys provided during construction mismatch those which might already be in the database. Ideally, it would surface an error code or exception type specifically for this case so that the SDK client can appropriately handle and recover from this.
How would this feature help you? A viewing key mismatch indicates either the SDK client might be using the API incorrectly or a corner case has occurred. Natural corner cases that could trigger this include:
Backup and restore of the database files through a filesystem backup. The users's mnemonic or spending key secret would not be restored, since it is kept in a hardware keystore that doesn't transfer between devices. If the user creates a new secret, the SDK would need to report a failure so that the SDK client could purge the old database files and perhaps display a message to the user. Non-atomic wipes of SDK state. If SDK state is reset, there are multiple files which need to be deleted. If a crash occurs during a deletion, the non-atomic nature of deleting multiple files could leave the client app and SDK in a bad state triggering this issue.