feat(wallet): add SSSS backup for wallet seed phrase
Adds ability to backup wallet seed phrase to Matrix SSSS: - WalletBackupService interface and implementation - New BACKUP_TO_MATRIX step in wallet setup flow - Recovery key input UI with FLAG_SECURE - Graceful handling of invalid keys and missing SSSS setup Users can now: 1. Write down seed phrase manually (existing) 2. Encrypt and store in Matrix account with recovery key The backup is encrypted with the same key used for cross-signing and message backup (SSSS).
This commit is contained in:
parent
86d6686aee
commit
0388cd7d06
5 changed files with 299 additions and 15 deletions
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2026 Sulkta Coop.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package io.element.android.features.wallet.api.backup
|
||||
|
||||
/**
|
||||
* Service for backing up and restoring wallet seed phrases using Matrix SSSS.
|
||||
*
|
||||
* The backup is encrypted with the user's Matrix recovery key and stored
|
||||
* in their account data, so it follows them across devices.
|
||||
*/
|
||||
interface WalletBackupService {
|
||||
/**
|
||||
* The secret name used to store the wallet seed in SSSS.
|
||||
*/
|
||||
companion object {
|
||||
const val SECRET_NAME = "com.sulkta.cardano.wallet_seed"
|
||||
}
|
||||
|
||||
/**
|
||||
* Backup the wallet seed phrase to Matrix SSSS.
|
||||
*
|
||||
* @param recoveryKey The Matrix recovery key (base58 encoded)
|
||||
* @param mnemonic The wallet seed phrase to backup
|
||||
* @return Success or error
|
||||
*/
|
||||
suspend fun backupSeed(recoveryKey: String, mnemonic: List<String>): Result<Unit>
|
||||
|
||||
/**
|
||||
* Restore a wallet seed phrase from Matrix SSSS.
|
||||
*
|
||||
* @param recoveryKey The Matrix recovery key
|
||||
* @return The mnemonic words if found, null if no backup exists
|
||||
*/
|
||||
suspend fun restoreSeed(recoveryKey: String): Result<List<String>?>
|
||||
|
||||
/**
|
||||
* Check if a wallet backup exists in SSSS.
|
||||
*
|
||||
* This can be called with the recovery key to verify a backup is present.
|
||||
*
|
||||
* @param recoveryKey The Matrix recovery key
|
||||
* @return True if a backup exists, false otherwise
|
||||
*/
|
||||
suspend fun hasBackup(recoveryKey: String): Result<Boolean>
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue