Concepts

The signer

The service that holds the keys, and what it requires before it signs.

The signer is a separate service that holds the agent wallets' keys. It is the only process that can decrypt one, and the API that talks to the chat agent and to outside agents has none.

The signer is not reachable from outside. Only the API calls it, with a shared secret, and it answers three requests.

RequestWhat it does
Create a walletGenerates the owner's agent keypair, once. A second request for the same owner returns the same address.
Sign a recordSigns the transaction message of one record, once.
WithdrawBuilds and signs a transfer from the agent wallet to the owner's own address.

No request returns a key.

Keys at rest

Each secret key is encrypted with AES-256-GCM under the signer's master key, with a random 12-byte nonce. The owner's id and the wallet's address are bound in as associated data, so a sealed key copied to another owner's row does not decrypt. After decrypting, the signer checks that the key's public key is the wallet's address.

Signing a record

The API sends only the record's id. The signer loads the record from the database itself and signs only when all of these hold:

CheckRefusal
The record exists.NOT_FOUND
Its decision is allow.NOT_ALLOWED
It has not been signed before.SPENT
The stored message hashes to the record's message_digest.DIGEST_MISMATCH
The message's fee payer is this owner's agent wallet.PAYER_MISMATCH
The message's blockhash is still valid.EXPIRED

It marks the record spent in the same database transaction that signs it, so two requests for one record produce one signature. The signer signs the stored message unchanged, so the message in the sent transaction hashes to the record's message_digest.

A refusal reaches the owner as a failed transaction whose error starts Not signed:. The record keeps its decision, nothing is sent, and the record does not count toward the 24-hour caps.

Withdrawals

The signer reads the owner's address from the database and sends only there.

  • lamports: "all" sends the balance less the network fee, and less the rent of the owner's token account when the same withdrawal has to open one.
  • A token withdrawal opens the owner's associated token account for the mint if it does not exist, then sends with TransferChecked.
  • An amount above what the wallet holds is refused with INSUFFICIENT_FUNDS.