Skip to main content
After this page, you know how recover gets the plaintext of the committed document and the account state, what the owner signs, how the SDK checks the reply, and when the plaintext is not available. The chain holds only the salted hash of the document. The plaintext lives in the engine, encrypted on the way in and on the way out. recover is the one public way to read it back.
Today, the engine accepts the sign-in of recover only when the EIP-4361 message names the domain of the Anafi dapp, app.ana.fi. The Anafi API refuses a sign-in for another domain with 422. An integration on another domain cannot complete this flow today. Keep your own copy of each document that you commit.

Preconditions

  • The signer is a signer of the account: an owner of the Safe, or the ERC20Allow address itself.
  • The client config has siweDomain, or the code runs in a browser where window.location.host gives the domain.
  • The call can reach the Anafi API. Today, the Anafi API hosts answer CORS only for https://app.ana.fi.

Sequence

Steps

1

Sign in

recover({ aa, eoa }) builds an EIP-4361 message with these fields and asks the wallet to sign it with signMessage (a sign-in message prompt):The message has no Expiration Time and no Resources. The engine accepts a recover sign-in only when its Resources list is empty, so a sign-in for another purpose cannot read the state.
2

Send the sealed request

The SDK reads AnafiRegistry.engineEncKey() and encrypts { aa, siwe_message, signature } to the engine. It keeps the key that opens the reply. It sends POST /api/wallets/{aa}/recover with { "sealed": ... }. See Sealed requests and Confidential channel.
3

Check the reply

The reply is sealed to this request. The SDK opens it and reads { state, engine_sig }. Then it:
  1. reads AnafiRegistry.engineSigKey();
  2. checks that engine_sig recovers to that key over keccak256(nonce ‖ state), with the state in a fixed JSON form. The nonce of this request is inside the digest, so a reply to an earlier request does not pass;
  3. checks the shape of state.tenant.
It returns state as RecoveredUserState. A failed check throws.

What can refuse

The recovered state

Parked reasons

A parked account starts again when a new commit is admitted. The row and its history stay.

Trust the plaintext only after a chain check

The engine signature proves that the engine wrote the reply. It does not prove that the reply is current. Before you show dsl.yaml as the live document:
  1. Read readDslCommitment(aa).
  2. Compare its hash with dsl.commitment. You can also compute dslCommitment(salt, yaml) when you hold the salt. The reply does not carry the salt.
  3. When they differ, the engine has not processed the latest commit yet, or it does not hold that text.

When the plaintext is not available

To tell the second case from the third, use the synced height of the engine:
  1. Read the identity on chain and note the block B of that read.
  2. Call readEngineSyncedHeight(). It makes one unauthenticated GET to the Anafi API’s status endpoint, with no wallet prompt. It returns the last block that the engine has processed, or null when the height is not known.
  3. When the height is below B, the engine has not reached the commit. Wait and read again. Do not ask the owner to sign in a loop.
  4. When the height is at or above B, call recover. When the reply still does not hold the committed document, the engine does not hold its text.

Example

The client must run where the sign-in domain is accepted. See the warning at the top of this page.