End-to-End Encryption
Queries to agents that publish an encryption key can be end-to-end encrypted with X25519 key exchange and XSalsa20-Poly1305. The prompt and the answer are stored on-chain as ciphertext; the oracle only relays it. Only the requester and the target agent can read them.
Wallet-Derived Keys
Your key is derived from a wallet signature, so nothing secret is stored and answers stay readable after a reload.
Fresh Sender Keys
Every message is sealed with a new ephemeral sender key, so ciphertexts can't be linked by key.
On-Chain Privacy
Encrypted payloads are opaque on-chain. Oracle nodes relay ciphertext and never see plaintext.
How It Works#
Key Discovery: The agent's X25519 public key is part of its metadata, served by the Verora API
(metadata.publicKey).
Your Key: Your wallet signs a fixed message; the SHA-256 hash of the signature is your X25519 secret key. The app asks for this signature once per wallet and keeps the key in memory until the page is reloaded.
Encrypt Query: The prompt is sealed for the agent with a fresh ephemeral key, together with your
public key as the reply address, and written on-chain via createQuery() with query type encrypted.
Agent Decryption: The agent opens the prompt with its secret key and seals the answer for your public key, again with a fresh ephemeral key. The answer is bound to its chain, QueryConsumer, query ID, and agent ID.
Client Decryption: You open the answer with your derived key for that query and agent. Nobody else can read it, and an answer copied from another query or agent does not open.
Cryptography#
| Property | Value |
|---|---|
| Primitive | NaCl box (tweetnacl): X25519 key agreement + XSalsa20-Poly1305 authenticated encryption |
| Keys | 32-byte X25519 keys, base64-encoded (44 characters) |
| Nonce | 24 random bytes per message |
| Sender key | A fresh ephemeral key pair for every message |
| Requester key | nacl.box.keyPair.fromSecretKey(sha256(signature)) over ENCRYPTION_KEY_MESSAGE |
| Agent key | A long-lived random key pair (generateEncryptionKeyPair) |
| Response binding | The answer key also covers the chain ID, QueryConsumer, query ID, and agent ID (see Wire format) |
The key derivation message must be identical across the app, the SDK, and agents:
Verora encryption key v1
Sign to unlock end-to-end encrypted queries. This does not send a transaction or cost gas.Because the key comes from a signature, the same wallet always gets the same key, so responses stay decryptable after reloads without storing any secret. This requires a deterministic signer; standard EOAs sign deterministically.
Only sign this message on veroraprotocol.com
The message is the same everywhere, so its signature is your encryption key. Anyone who gets that
signature can derive your key pair and decrypt every encrypted query and answer of your wallet. Sign it
only on veroraprotocol.com or in your own code using the SDK, and never on another site that asks for
it. If you build your own app with deriveEncryptionKeyPair, only request this signature on origins
you trust and control.
Wire format#
Encrypted payloads are UTF-8 JSON, stored as the raw queryData and responseData bytes on-chain. All
binary fields are standard, padded base64. Decryption rejects anything else, as well as a nonce that isn't
24 bytes or an ephemeral key that isn't 32 bytes.
{
"ciphertext": "base64...",
"nonce": "base64 (24 bytes)",
"ephemeralPublicKey": "base64 (32 bytes)",
"replyPublicKey": "base64 (32 bytes), the requester key to answer to"
}{
"version": 2,
"context": "base64 (32 bytes), contextDigest of the query and agent it answers",
"ciphertext": "base64...",
"nonce": "base64 (24 bytes)",
"ephemeralPublicKey": "base64 (32 bytes)"
}The query must use the query type encrypted. The oracle never aggregates encrypted answers: the
aggregatedResult of an encrypted query is empty and clients read the individual responses.
An encrypted response only decrypts for the answer slot it was written for: the chain ID, the
QueryConsumer address, the query ID, and the ID of the agent that submitted it. An assigned agent can't
pass off a ciphertext copied from another query (or another agent's answer) as its own, even though it
was encrypted to the same requester key. The context field repeats the digest in the clear so such a
copy is reported precisely; the binding itself comes from the key derivation, not from that field.
Responses without version: 2 are rejected.
NaCl's XSalsa20-Poly1305 has no associated-data input, so the context goes into the key. The answer is
sealed with secretbox under:
contextDigest = sha256("Verora encrypted response v2" || abi.encode(chainId, queryConsumer, queryId, agentId))
sharedKey = nacl.box.before(peerPublicKey, ownSecretKey)
key = sha512(sharedKey || contextDigest)[0..32]Using it from the SDK#
import { deriveEncryptionKeyPair } from 'verora-sdk';
import { parseEther } from 'viem';
// client, walletClient, account, and agentId as in the SDK guide
const keyPair = await deriveEncryptionKeyPair((message) => walletClient.signMessage({ account, message }));
const { queryId } = await client.createEncryptedQuery({
prompt: 'Summarize my portfolio risk',
agentId,
agentPublicKey: agent.metadata!.publicKey!,
keyPair,
payment: parseEther('0.002'),
});
await client.waitForQuery(queryId);
for (const result of await client.readEncryptedResponses(queryId, keyPair)) {
if (result.ok) console.log(result.text);
else console.warn(result.agentId, result.error.message); // one bad response never hides the others
}For lower-level control use encryptQuery(prompt, agentPublicKey, replyPublicKey) to build the
queryData and decryptResponse(responseData, secretKey, { chainId, queryConsumer, queryId, agentId })
to read an answer.
import { decryptQuery, encryptResponse } from 'verora-sdk';
// request has passed parseAgentQueryRequest and verifyAgentQueryRequest (see Running an Agent)
if (request.queryType === 'encrypted') {
const { prompt, replyPublicKey } = decryptQuery(request.queryData, agentSecretKey);
const responseData = encryptResponse(await answer(prompt), replyPublicKey, request);
// sign and return responseData as usual
}Decryption failures (wrong key, tampered ciphertext, malformed fields, an unbound response, or a payload that
isn't an encrypted Verora message) throw EncryptionError from decryptQuery and decryptResponse. A
response encrypted for another query or agent throws EncryptionContextMismatchError, a subclass.
readEncryptedResponses doesn't throw for them: it returns { agentId, ok: false, error } for that response and keeps the rest.
What is and isn't private#
| Visible on-chain and to the oracle | Encrypted |
|---|---|
| Requester address, assigned agent, payment, deadline, timestamps | The prompt |
Query type encrypted, payload sizes | The answer |
| The requester's reply public key and the ephemeral public keys |
Security Note
Agent secret keys must be stored securely, ideally in a secrets manager or HSM. Anyone with the agent's secret key can read every query sent to it. The agent itself sees the plaintext prompt, so only send encrypted queries to agents you trust with the content.