IWalletBackupManager
Public interface for WalletBackupManagerFacet on the FlareTeeManager diamond.
This facet starts a restore of a wallet key.
It does not hold the private key.
The backupRestore call asks the data providers and key admins to rebuild a key on a TEE that does not have it.
The directBackup and directRestore calls move a key that a TEE still holds to one other TEE.
The project owner or that project's backup manager makes each call.
The call is payable and pays the instruction fee.
Each call sends one F_WALLET instruction to a TEE that is in PRODUCTION on the wallet's extension.
Inherits shared ITeeCommonErrors.
FCC and Protocol Managed Wallets are in the final stages of development. Prefer Coston2 for examples and treat interfaces as subject to change.
Types
BackupId
Identifies one backup of one wallet key.
The TEE that produced the backup is teeId.
The rewardEpochId field is the signing policy whose data-provider weights the shares were cut against.
The randomNonce field separates two backups of the same key in the same reward epoch.
struct BackupId {
address teeId;
bytes32 walletId;
uint64 keyId;
bytes32 keyType;
bytes32 signingAlgo;
bytes publicKey;
uint32 rewardEpochId;
bytes32 randomNonce;
}
KeyDataProviderRestore
Payload of the F_WALLET / KEY_DATA_PROVIDER_RESTORE instruction sent by backupRestore.
The teePublicKey field is the destination TEE.
The nonce field is the key nonce after this call increments it.
struct KeyDataProviderRestore {
PublicKey teePublicKey;
BackupId backupId;
string backupUrl;
uint256 nonce;
}
KeyDirectBackup
Payload of the F_WALLET / KEY_DIRECT_BACKUP instruction sent by directBackup.
The source TEE encrypts the wallet key to destinationTeePublicKey.
The machinePathListNonce field selects the governance-signed machine-path list the TEE checks.
struct KeyDirectBackup {
address sourceTeeId;
bytes32 walletId;
uint64 keyId;
PublicKey destinationTeePublicKey;
uint256 machinePathListNonce;
}
KeyDirectRestore
Payload of the F_WALLET / KEY_DIRECT_RESTORE instruction sent by directRestore.
The destination fetches the ciphertext from sourceProxyUrl at backupInstructionId.
The destinationNonce field is the key nonce after this call increments it.
The destination's restore proof binds to that nonce.
struct KeyDirectRestore {
address sourceTeeId;
string sourceProxyUrl;
BackupId backupId;
bytes32 backupInstructionId;
uint256 destinationNonce;
uint256 machinePathListNonce;
}
Functions
backupRestore
Starts a data-provider restore of a wallet key onto _teeId.
Emits BackupRestoreTriggered.
The project owner or the project's backup manager calls it.
The destination TEE must be in PRODUCTION on the wallet's extension and must not already hold the key.
The TEE named in _backupId.teeId must not be INITIALIZED.
The backup's public key, key type, and signing algorithm must match the confirmed key.
The contract accepts _backupId.rewardEpochId when it is at most the current reward epoch plus one.
An older backup can still fail later, when too few of that epoch's data providers can open their shares.
The call increments the key nonce on the destination, then sends one F_WALLET / KEY_DATA_PROVIDER_RESTORE instruction.
The instruction's cosigners are the wallet's key admins, and its cosigner threshold is the wallet's admin threshold.
Data providers and key admins then submit shares to the destination proxy.
After the TEE returns a key-existence proof, the project owner or the backup manager calls confirmKey to record the new holder.
function backupRestore(
address _teeId,
BackupId calldata _backupId,
string calldata _backupUrl,
address _claimBackAddress
)
external payable
Parameters
_teeId: The TEE the key will be restored onto._backupId: The backup to restore._backupUrl: The URL of the backup package._claimBackAddress: The address that can claim the fee back if the instruction is not executed. Pass the zero address to skip it.
Reverts
OnlyOwnerOrBackupManagerwhen the caller is not the project owner or the backup manager.TeeMachineNotAvailablewhen the destination TEE is not inPRODUCTION.InvalidTeeMachinewhen the TEE in_backupId.teeIdisINITIALIZED.KeyAlreadyAvailablewhen the destination already holds the key.KeyNotConfirmedwhen the wallet has no confirmed public key for this key id.InvalidPublicKeywhen_backupId.publicKeydoes not match the stored public key.InvalidKeyTypewhen_backupId.keyTypedoes not match the project.InvalidSigningAlgowhen_backupId.signingAlgodoes not match the project.ExtensionIdMismatchwhen the backup TEE, the destination TEE, and the wallet's project are not the same extension.InvalidRewardEpochIdwhen_backupId.rewardEpochIdis greater than the current reward epoch plus one.
directBackup
Asks a TEE that holds the key to encrypt it for one other TEE.
Emits DirectBackupTriggered.
Returns the instruction id the later directRestore fetches.
The project owner or the project's backup manager calls it.
Both TEE machines must be in PRODUCTION on the wallet's extension.
The extension's active machine-path list must include this pair: the source in a path's source set and the destination in that same path's destination set.
The source must currently hold the key, and the destination must not.
This call does not change the destination's key nonce.
A failed directRestore can be retried against the same instruction id.
function directBackup(
address _sourceTeeId,
address _destinationTeeId,
bytes32 _walletId,
uint64 _keyId,
address _claimBackAddress
)
external payable
returns (bytes32 _instructionId)
Parameters
_sourceTeeId: The TEE that currently holds the key._destinationTeeId: The TEE a laterdirectRestorewill import the key onto._walletId: The wallet id._keyId: The key id._claimBackAddress: The address that can claim the fee back if the instruction is not executed. Pass the zero address to skip it.
Returns
_instructionId: The id of theKEY_DIRECT_BACKUPinstruction. Pass it todirectRestore.
Reverts
OnlyOwnerOrBackupManagerwhen the caller is not the project owner or the backup manager.TeeMachineNotAvailablewhen the source or the destination is not inPRODUCTION.ExtensionIdMismatchwhen either TEE is outside the wallet's extension.NoActiveMachinePathListwhen the extension has no signed machine-path list.InvalidMachinePathwhen the active list does not allow this source and destination pair.KeyNotConfirmedwhen the wallet has no confirmed public key for this key id.SourceTeeDoesNotHoldKeywhen the source is not a current holder.KeyAlreadyAvailablewhen the destination already holds the key.
directRestore
Imports a key onto the destination TEE from a blob produced by directBackup.
Emits DirectRestoreTriggered.
The project owner or the project's backup manager calls it.
The destination fetches the ciphertext from the source TEE's proxy at _backupInstructionId.
The call increments the destination's key nonce, and the restore proof binds to the new nonce.
The backup's reward epoch must be the current reward epoch or the one before it.
The same machine-path pair required by directBackup must still be in the active list.
The instruction has no cosigners.
Data providers still sign it with more than half the signing-policy weight.
function directRestore(
address _destinationTeeId,
BackupId calldata _backupId,
bytes32 _backupInstructionId,
address _claimBackAddress
)
external payable
returns (bytes32 _instructionId)
Parameters
_destinationTeeId: The TEE the key will be restored onto._backupId: The backup id of the blob fromdirectBackup. TheteeIdin that id is the source TEE._backupInstructionId: The instruction id returned bydirectBackup._claimBackAddress: The address that can claim the fee back if the instruction is not executed. Pass the zero address to skip it.
Returns
_instructionId: The id of theKEY_DIRECT_RESTOREinstruction.
Reverts
OnlyOwnerOrBackupManagerwhen the caller is not the project owner or the backup manager.TeeMachineNotAvailablewhen the destination is not inPRODUCTION.InvalidTeeMachinewhen the source TEE in_backupId.teeIdisINITIALIZED.KeyAlreadyAvailablewhen the destination already holds the key.KeyNotConfirmedwhen the wallet has no confirmed public key for this key id.InvalidPublicKeywhen_backupId.publicKeydoes not match the stored public key.InvalidKeyTypewhen_backupId.keyTypedoes not match the project.InvalidSigningAlgowhen_backupId.signingAlgodoes not match the project.ExtensionIdMismatchwhen the source TEE, the destination TEE, and the wallet's project are not the same extension.InvalidRewardEpochIdwhen_backupId.rewardEpochIdis not the current reward epoch or the one before it.NoActiveMachinePathListwhen the extension has no signed machine-path list.InvalidMachinePathwhen the active list does not allow this source and destination pair.
Events
BackupRestoreTriggered
Emitted when backupRestore sends the restore instruction.
The nonce field is the destination key nonce after the call increments it.
event BackupRestoreTriggered(
address indexed teeId,
bytes32 indexed walletId,
uint64 indexed keyId,
uint256 nonce
)
Parameters
teeId(address indexed teeId): The destination TEE.walletId(bytes32 indexed walletId)keyId(uint64 indexed keyId)nonce(uint256 nonce)
DirectBackupTriggered
Emitted when directBackup sends the backup instruction.
The backupInstructionId value is what a later directRestore call fetches.
event DirectBackupTriggered(
address indexed sourceTeeId,
address indexed destinationTeeId,
bytes32 indexed walletId,
uint64 keyId,
bytes32 backupInstructionId
)
Parameters
sourceTeeId(address indexed sourceTeeId)destinationTeeId(address indexed destinationTeeId)walletId(bytes32 indexed walletId)keyId(uint64 keyId)backupInstructionId(bytes32 backupInstructionId)
DirectRestoreTriggered
Emitted when directRestore sends the restore instruction.
The destinationNonce field is the destination key nonce after the call increments it.
event DirectRestoreTriggered(
address indexed destinationTeeId,
bytes32 indexed walletId,
uint64 indexed keyId,
uint256 destinationNonce,
bytes32 backupInstructionId
)
Parameters
destinationTeeId(address indexed destinationTeeId)walletId(bytes32 indexed walletId)keyId(uint64 indexed keyId)destinationNonce(uint256 destinationNonce)backupInstructionId(bytes32 backupInstructionId)
Errors
Facet-specific errors are listed here.
The interface also inherits shared ITeeCommonErrors, including OnlyOwnerOrBackupManager, TeeMachineNotAvailable, ExtensionIdMismatch, InvalidKeyType, InvalidSigningAlgo, and InvalidPublicKey.
InvalidTeeMachine
The TEE named as the source in BackupId.teeId is still INITIALIZED.
error InvalidTeeMachine()
KeyAlreadyAvailable
The destination TEE already holds this wallet key.
error KeyAlreadyAvailable()
KeyNotConfirmed
The wallet has no confirmed public key for this key id.
error KeyNotConfirmed()
InvalidRewardEpochId
The backup's reward epoch is outside the range for this call.
The backupRestore call accepts an epoch up through the current reward epoch plus one.
The directRestore call accepts the current reward epoch or the one before it.
error InvalidRewardEpochId()
SourceTeeDoesNotHoldKey
The directBackup call named a source TEE that is not a current holder of the key.
error SourceTeeDoesNotHoldKey()