Skip to content
LogoLogo

Encrypted transport

Endpoint

POST /info, /exchange and /v1/financial-identity, using Content-Type: application/vnd.hermit.encrypted+json.

WebSocket /ws, carrying encrypted application frames after channel takeover.

Create and verify a private channel first. The envelope wraps existing API routes.

Purpose

Encrypt API payloads to the attested enclave key. The host relays ciphertext only.

Browsers cannot inspect TLS peer keys or exporters, so verify the application key instead. Native clients can use TLS attestation.

Authorization

The channel verifies the enclave. Account access still requires request signatures; channel IDs grant no account permission.

Encoding conventions

Binary JSON fields use canonical URL-safe base64 without padding. Decode them to bytes before hashing or concatenating. || below means byte concatenation. UTF8(s) encodes a string; U16BE, U64BE and U8 encode unsigned integers at the stated width. All lengths count encoded bytes. JSON integer fields must be safe integers; sequences are canonical unsigned decimal strings from "0" through "18446744073709551615", without signs or leading zeros.

The protocol label is the exact UTF-8 byte string:

hermit.attested-channel.v1

L is this byte string; 0x00 is one zero byte.

Verify the handshake

Generate a fresh P-256 ECDH key pair and a cryptographically random 32-byte nonce. Send the 65-byte uncompressed SEC1 client public key and nonce in the handshake request. The configured deployment identity comes from the integrator's trusted configuration.

Decode the response's sessionId to 32 bytes and serverPublicKey to a 65-byte uncompressed P-256 point. The binary transcript is:

T = L || 0x00
    || U16BE(length(UTF8(deployment))) || UTF8(deployment)
    || sessionId[32]
    || clientPublicKey[65]
    || serverPublicKey[65]
    || nonce[32]
    || U64BE(expiresAt)

Verify the Nitro COSE document before sending private data:

  1. Verify the certificate chain against the pinned AWS Nitro root and the COSE ES384 signature. A root supplied by the service is not a trust anchor.
  2. Verify the signed timestamp and certificate validity against a trusted clock and the configured freshness policy. Reject expired channels and disallowed future timestamps.
  3. Match one complete approved PCR0/PCR1/PCR2 tuple from the independently distributed build policy. Where a tuple requires PCR8, match it within that same tuple. Do not mix measurements from different approved builds or accept debug measurements.
  4. Require the signed nonce to equal the fresh 32-byte challenge, public_key to equal the server's raw application public key, and user_data to equal L || 0x00 || SHA256(T).
  5. Require the response deployment to match the configured deployment, and bound expiresAt by the trusted client policy. Track expiry with a monotonic deadline as well as the wall clock.

Distribute the verifier and approved-build policy independently. Server-provided status or allowlists cannot replace verification.

Derive the encryption keys

Use fresh-client/attested-server P-256 ECDH. Its 32-byte secret is the HKDF input:

salt = SHA256(T)
PRK  = HKDF-Extract-SHA256(salt, ECDH_shared_secret)
Kc2s = HKDF-Expand-SHA256(PRK, L || 0x00 || UTF8("c2s"), 32)
Ks2c = HKDF-Expand-SHA256(PRK, L || 0x00 || UTF8("s2c"), 32)

Use independent directional AES-256-GCM keys. Append the 128-bit tag. IV for sequence n:

IV(n) = 0x00000000 || U64BE(n)

Never repeat a sequence under the same directional key. A new handshake creates new keys and a new session identifier. Keep client private and derived keys nonextractable where the cryptographic runtime supports it.

Request fields

HTTP bodies and WebSocket frames use:

FieldTypeRequiredMeaning
versionIntegerYes1.
sessionIdStringYesBase64url encoding of the established 32-byte channel identifier.
sequenceStringYesExact expected unsigned 64-bit sequence in canonical decimal notation.
ciphertextStringYesBase64url encoding of AES-GCM ciphertext followed by its 16-byte tag.

Reject mismatched version/session identifiers, replayed or reordered sequences, invalid encodings and failed authentication tags.

HTTP plaintext

Encrypt UTF-8 JSON:

FieldTypeRequiredMeaning
authorizationObjectFor /infoThe request's timestamp, nonce and signature. These correspond to the three signed-read headers in request authorization.
bodyObjectYesThe native query body for /info, complete signed action envelope for /exchange, or nonce discovery body for /v1/financial-identity.

The read authorization object contains exactly timestamp (safe integer Unix milliseconds), nonce (0x followed by 32 bytes) and signature (canonical low-S 65-byte signature with recovery byte 27 or 28). Hash and sign the logical body according to the shared request-authorization specification. Carry this proof inside the ciphertext rather than in outer HTTP headers or cookies.

For /v1/financial-identity, omit authorization and use body: {nonce} with a fresh standard-base64 32-byte nonce. Verify the returned nonce and identity against your trusted configuration on this same channel. This public discovery call grants no customer permission.

For /exchange, omit authorization: the complete action, nonce and action signature are already inside body. No read signature is substituted for the trading or owner-withdrawal proof.

Authenticated additional data

AAD binds the target and response status. Use decoded bytes:

AAD = L || 0x00
      || sessionId[32]
      || U64BE(sequence)
      || U8(direction)
      || U16BE(length(method)) || ASCII(method)
      || U16BE(length(path)) || ASCII(path)
      || U16BE(status)
Transport and directiondirectionmethodpathstatus
HTTP client request0POSTExact /info, /exchange or /v1/financial-identity0
HTTP server response1POSTSame path as the requestActual HTTP status
WebSocket client frame0GET/ws0
WebSocket server frame1GET/ws200

Paths contain no origin, query string or fragment. GET in the WebSocket AAD identifies the upgrade route; it does not turn each application frame into a new HTTP request.

HTTP sequencing

A fresh channel starts at sequence 0. Serialize HTTP exchanges within a channel: the request and its response use the same sequence with different directional keys, then the next exchange increments that sequence by one. Do not send a second request before authenticating the first response. Use a separate independently established channel when concurrent HTTP exchanges are required.

WebSocket takeover

Permanently transfer a channel to one /ws connection after completing any pending HTTP exchange. Disable further HTTP use of those keys before sending the first WebSocket frame. The first encrypted client frame uses the next HTTP sequence and starts the WebSocket session; the server removes the channel from its HTTP manager.

The decrypted client frame is {"body": <logical WebSocket message>}. A private subscribe or unsubscribe message contains its auth metadata within that logical message. A post message contains its signed trading payload and needs no additional read authorization. Do not duplicate either proof in an outer authorization property.

After takeover, each direction has its own strictly increasing counter. The first server frame uses the takeover sequence; later server frames increment once per frame. The client's subsequent frames increment from its takeover sequence independently of how many server messages arrive. Every acknowledgement, snapshot, update and application error is encrypted. WebSocket protocol control frames carry no customer payload.

Request example

Example /info plaintext. This is a frozen fixture; regenerate its proof before use.

{
  "authorization": {
    "timestamp": 1796250000000,
    "nonce": "0x0101010101010101010101010101010101010101010101010101010101010101",
    "signature": "0x6b39d528cc6f043b7068fd1e66dbddf02ef55865b14a955cc112072685b4f43a408bb707500a309e6e3dc360f003479569e3b69980f8c9461bbbbfb808fb78cd1c"
  },
  "body": {
    "type": "openOrders",
    "user": "0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf"
  }
}

Encrypt with Kc2s, the next IV and request AAD. Send to the original route:

POST /info HTTP/1.1
Content-Type: application/vnd.hermit.encrypted+json
Accept: application/vnd.hermit.encrypted+json
{
  "version": 1,
  "sessionId": "<base64url-encoded 32-byte session identifier>",
  "sequence": "0",
  "ciphertext": "<base64url-encoded ciphertext and GCM tag>"
}

For a WebSocket subscription, the plaintext before encryption instead has this shape:

{
  "body": {
    "method": "subscribe",
    "subscription": {
      "type": "openOrders",
      "user": "0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf"
    },
    "auth": {
      "timestamp": 1796250000000,
      "nonce": "0x0303030303030303030303030303030303030303030303030303030303030303",
      "signature": "0xca60c8cb82aa8b58b8283a3a2c324a0cba31c4162b0c942523f7c53f2f54ce455b072a9f2bdca857ae08d5b27bf01f746d011a30bdce4b8b5ea72dad34b55f4b1c"
    }
  }
}

Sequences, read nonces, trading nonces and post IDs are not interchangeable.

Response fields

Encrypted responses use the same four envelope fields: version, sessionId, sequence and ciphertext. Validate the expected session and sequence before decrypting with Ks2c, the server-direction IV and AAD. For HTTP, authenticate the actual response status; a host cannot change it without invalidating the tag.

The decrypted response is the native API JSON result directly. It has no body or authorization wrapper. The same rule applies to WebSocket server frames: their decrypted content is the normal subscriptionResponse, private stream message, post response or application pong documented on the WebSocket pages.

Response example

An HTTP response has the encrypted media type and an envelope:

HTTP/1.1 200 OK
Content-Type: application/vnd.hermit.encrypted+json
Cache-Control: no-store
{
  "version": 1,
  "sessionId": "<same base64url-encoded session identifier>",
  "sequence": "0",
  "ciphertext": "<base64url-encoded response ciphertext and GCM tag>"
}

For an authorized openOrders query with no open orders, the authenticated plaintext is:

[]

Generate ciphertext from the actual channel keys, sequence, target and status. Obtain attestation at runtime.

Constraints

  • Use HTTPS and WSS on port 443. Never downgrade to HTTP, plaintext WebSocket or an unverified application channel. Keep wallet proofs and private data out of URL paths, query strings, outer credentials and logs.
  • The channel expires at expiresAt; the service's channel lifetime is 60 seconds. Reconnect with a fresh handshake, nonce and keys before continuing after expiry. A clock rollback must not extend an admitted channel.
  • A session is either serialized HTTP or exclusively owned by one WebSocket. It is never shared concurrently between them and never returned to HTTP after takeover.
  • Do not retry ciphertext or reuse keys after a lost, invalid, expired or ambiguous response. Close the channel and independently verify a new one. Reconcile the operation's business outcome before creating a replacement action.
  • Require the encrypted response media type. A plaintext response, redirect, mismatched session/sequence, invalid UTF-8/JSON, failed tag or policy revocation closes the admitted channel. An authenticated API error can be decoded for diagnostics; the channel is closed before further requests.
  • Request plaintext is limited to 16 KiB, including its proof wrapper; response plaintext is limited to 1 MiB. Handshake request JSON is limited to 4 KiB and encrypted HTTP request JSON to 24 KiB. Bound client queues and socket buffering; a slow consumer may be disconnected.
  • P-256 application ECDH provides this browser channel's key agreement. It does not provide post-quantum end-to-end secrecy. Native attested hybrid TLS is a separate transport.
  • Encryption preserves the supported API scope, customer permission checks and WebSocket subscription limits. It does not expose public market-data queries or grant withdrawal authority.