Agent documentation index: llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Skip to main content

Machine Keys and Wallet Keys

Registering a Flare Compute Extension gives it an extension ID, an owner, and the contract that sends its instructions. A TEE machine boots and generates an identity key for itself. Later, once that machine is in production and the wallet's key admins have accepted the role, an instruction from the chain asks the machine to generate a wallet key. The same machine can generate several wallet keys.

The diagram below shows the sequence of events.

Who Acts​

RoleWhat they holdWhat they do
Extension ownerThe extension.
No private key.
Calls register.
Adds to the extension's allowlist machine owners and project owners.
Adds the code hash and the supported key types.
Machine ownerOne registered TEE machine.Registers that machine, brings it to production, and can pause it.
The address must be on the extension's machine-owner allowlist.
Project ownerThe wallet project.Creates the project and its wallets, names the key admins, calls addKey, and calls confirmKey.
Key adminsOne backup share each.
The wallet key itself stays in the TEE.
Call confirmAdmin before the wallet can start.
On a share restore, they open their share and re-encrypt it to the destination TEE.

The extension owner, the machine owner, and the project owner are three different allowlists. The owner allowlists page describes who can update each list. Taking a machine owner off the list blocks new registration and ownership transfer. A machine that an address already owns keeps that owner.

The Machine Key​

When the enclave boots, tee-node generates a secp256k1 identity key inside the enclave. The public key address is the TEE id. Registration sends that public key and a signature that recovers to it, so the chain attaches this TEE id to the extension. After a data-provider attestation, the machine owner calls toProduction.

This key signs extension results, attestations, and the proof that a wallet key exists on the machine. Callers encrypt to its public key when only this enclave should read the payload. The extension application never receives the private half. A reboot generates a new identity key, so the chain sees a new machine. The identity key is not included in a wallet-key backup.

The operator sets initialOwner on the machine before registration. The register call succeeds when the caller is that initial owner and isAllowedTeeMachineOwner is true for this extension.

The Wallet Key​

Wallet keys exist when the extension owner has added supported key types, such as EVM or XRP. An address on the project-owner allowlist calls createProject with this extension id and one key type. The project is pinned to that extension, so its keys can be generated only on TEE machines registered to it. The createWallet call then leaves the wallet in CREATED status.

The wallet key appears only after admins confirm. Read the calls downward.

The project owner calls setAdmins with the admin public keys and a threshold. The threshold is how many of those admins must take part before the admin half of a backup can be rebuilt. With 3 admins and a threshold of 2, any 2 of the 3 are enough, and 1 is not. The threshold is at least 1 and no higher than the number of admins. A wallet can name at most 50 admins. Each admin calls confirmAdmin from the address of their public key. The closeWalletInitialization call reverts with an AdminsNotSet error when the list is empty, and with a NotAllAdminsConfirmed error when a named admin has not confirmed. Cosigners are optional. After initialization, the admin list and the threshold stay fixed for the life of the wallet. That list is copied into the key record on every TEE that generates or restores the key.

The project owner then calls addKey with a TEE id that is in production on the same extension. The call pays the fee and sends one F_WALLET / KEY_GENERATE instruction. The FlareTeeManager contract emits that instruction. Data providers read it from the chain, sign it, and relay it to the machine's proxy. The TEE pulls it from the proxy. The TEE's tee-node generates the wallet private key inside the enclave, beside the identity key. It will not generate the key if that instruction arrives with an empty admin list or a threshold of zero. The identity key signs a key-existence proof. The project owner, or later the project's backup manager, submits that proof to confirmKey. The chain stores the wallet public key and records this TEE id as a holder.

A wallet key can sign an external action. The key type limits what it can sign. An EVM key signs an EVM transaction. An XRP key signs an XRP Ledger transaction. A key with the random-number signing algorithm signs a proof that this key produced one random number for a given input. The machine key only vouches that the wallet key is on that machine. One wallet can hold several keys, on one machine or on several. The project owner calls setMultisigThreshold to choose how many of those keys must sign. The addKey call is accepted while the wallet is in INITIALIZED status. After the enableWallet call moves it to production, the contract rejects further addKey calls.

The Wallets Extension guide walks through an EVM signing example on top of this setup.

Backup​

The machine's proxy requests a backup package with F_GET / TEE_BACKUP when the key is generated. It requests a new package each time the TEE installs a new signing policy. A signing policy is the data provider set for one reward epoch. A reward epoch is 3,360 voting epochs of 90 seconds, which is 3.5 days. In most cases the epoch lasts that long. The backup id records that reward epoch, because the provider shares are cut against that epoch's weights.

The TEE splits the wallet private key into two random halves that add back to the key. One half is shared among the data providers in the active signing policy. The TEE scales their voting weights so those weights add up to 1,000, and gives each provider a share of that size. Rebuilding that half takes shares that add up to 666 of the 1,000. The other half is shared among the key admins, one share each. Rebuilding it takes the admin threshold set above, for example, 2 of the 3 named admins.

Both halves are required. The key comes back only when each half has been rebuilt.

Each share is encrypted to that holder's public key. The wallet key signs the package, so the shares belong to that key. The machine identity key signs it as well, so the package came from that TEE. The project's backup manager fetches the package from the source machine's proxy and stores it at a URL. The backup manager cannot read the shares.

The backupRestore call accepts a backup from the current reward epoch, from any earlier epoch, or from the next one. An older backup can fail once too many of that epoch's providers have left the signing policy, because their shares no longer add up to 666.

Restore follows one of the two paths below. Both paths end with a call to confirmKey.

Direct Restore​

Use this path while some TEE of the extension still holds the key. Read the calls downward. The machine path list must already allow this pair.

The project owner or the backup manager calls directBackup for a source TEE and a destination TEE. The source encrypts the whole wallet private key under the destination TEE's public key. That instruction is F_WALLET / KEY_DIRECT_BACKUP. The directRestore call sends the KEY_DIRECT_RESTORE instruction to the destination. The destination proxy fetches the ciphertext from the source proxy, and the destination decrypts it with its own identity key.

The extension's governance signers must already have allowed this source TEE to pass the key to this destination TEE. That permission sits in a machine path list, installed with the F_GOVERNANCE / SET_MACHINE_PATH_LIST system instruction. The source TEE has to be in a path's source set, and the destination TEE in that same path's destination set. Data providers still sign these instructions with more than half the signing-policy weight. The destination accepts the package when the backup's reward epoch is the current one or the one just before it.

Data Provider Restore​

Use this path when no running TEE still holds the key. Read the calls downward. The target TEE is in production and does not already hold the key.

The project owner or the backup manager calls backupRestore with the target TEE, the backup id, and the URL of the package. The contract emits BackupRestoreTriggered and sends one F_WALLET / KEY_DATA_PROVIDER_RESTORE instruction to the target. The target is in production on the same extension and does not already hold the key.

Each data provider from the backup's reward epoch, and each key admin, fetches the package, decrypts only the share addressed to their own key, and encrypts that share to the target TEE's public key. Data providers read the instruction from the chain, sign it, and relay it to the target proxy, bringing their share with that signed instruction. Key admins are the instruction's cosigners. They submit their share to the same proxy, and the cosigner threshold is the wallet's admin threshold. The shares stay encrypted, so the proxy cannot read them. The TEE runs the restore after the data-provider signatures pass more than half the signing-policy weight. It adds the two halves back into the same wallet private key once the provider shares cover 666 of 1,000 and the admin count reaches the wallet's admin threshold, checks the public key, and stores that key. The key-existence proof it returns has restored set, marking this copy as rebuilt from the backup. The confirmKey call records the new TEE id. The wallet public key stays the same.

Until that confirmation, signing instructions do not reach the new machine. With no holder in production, a sign call such as the wallet example's signTransaction reverts with a ThresholdNotMet error. A key that cannot be restored is gone, and an enabled wallet cannot gain a replacement key.

What's next

To learn more about the FCC, read the following guides: