Hanzo ZT

Architecture

ZT fabric, transport layer, authentication flow, and network topology

Architecture

Hanzo ZT uses a controller-managed overlay network with a decentralized data plane. The controller handles identity, policy, and certificate management while the data plane routes traffic directly between nodes through encrypted tunnels.

Network Topology

                    ZT Controller
                   (identity + policy + certificates)
                    /            \
                   /              \
            ZT Node A          ZT Node B
           (mTLS cert)        (mTLS cert)
                \                /
                 \              /
                  ZT Fabric
              (encrypted tunnels)
                      |
                  ZAP Transport
              (Cap'n Proto RPC)

Key principles:

  • The controller is a centralized management plane — it never sees application data
  • The data plane is fully decentralized — nodes connect directly via UDP hole punching
  • All traffic is mTLS encrypted with x509 certificates issued by the controller
  • NAT traversal is automatic — no open ports, no firewall rules required

Transport Stack

The full transport stack from application to wire:

LayerProtocolPurpose
ApplicationYour codeBusiness logic using SDK APIs
ZAPCap'n Proto RPC4-byte BE length-prefix framing, zero-copy serialization
ZT TransportmTLSx509 certificate-based encryption and authentication
ZT FabricOverlayVirtual L2/L3 network with software-defined routing
PhysicalUDPHole punching through NATs and firewalls

Authentication Flow

Every connection goes through this authentication sequence:

 Client                      ZT Controller              Commerce API
   |                              |                          |
   |  1. Present JWT              |                          |
   |----------------------------->|                          |
   |                              |                          |
   |  2. Validate JWT             |                          |
   |  3. Issue x509 cert          |                          |
   |<-----------------------------|                          |
   |                              |                          |
   |  4. Check balance            |                          |
   |---------------------------------------------------->   |
   |                              |                          |
   |  5. Balance OK               |                          |
   |<----------------------------------------------------|  |
   |                              |                          |
   |  6. Dial service (mTLS)      |                          |
   |============================================>  Service   |

Step by step:

  1. JWT presentation — Client sends Hanzo IAM JWT to controller at /edge/client/v1/authenticate?method=ext-jwt
  2. JWT validation — Controller validates the JWT signature and claims
  3. Certificate issuance — Controller issues a short-lived x509 mTLS certificate bound to the client's identity
  4. Balance check — Client calls GET /v1/billing/balance?service=NAME on the Commerce API
  5. Balance OK — Commerce API confirms positive balance (no free tier)
  6. Service dial — Client establishes mTLS connection through the fabric to the target service

Billing Integration

Billing is enforced at the transport layer, not the application layer. This means every dial() call is metered regardless of what protocol runs on top.

dial() ──> balance_check ──> connect ──> [transfer data] ──> close ──> record_usage
PhaseEndpointMethodDescription
Pre-dial/v1/billing/balanceGETCheck balance is positive
Post-session/v1/billing/usagePOSTRecord bytes sent/received and duration

The UsageRecord includes:

  • service — Name of the dialed service
  • session_id — Unique session identifier
  • bytes_sent / bytes_received — Data transferred
  • duration_ms — Session duration in milliseconds

ZAP Framing

ZAP uses a simple 4-byte big-endian length-prefix framing protocol:

+---+---+---+---+---+---+---+---+---+---+---+---+---+
| Length (4B BE) |      Cap'n Proto Payload (N bytes)  |
+---+---+---+---+---+---+---+---+---+---+---+---+---+

Each frame consists of:

  1. 4 bytes: Big-endian uint32 containing the payload length
  2. N bytes: Cap'n Proto serialized message

This is the same framing used by all 6 SDKs, ensuring cross-language interoperability.

Service Discovery

Services are registered with the ZT controller and discovered at dial time:

ctx.services()       →  GET /edge/client/v1/services
                        Returns: [{ name, id, permissions, configs }]

ctx.dial("my-svc")  →  1. Lookup service by name
                        2. Find edge routers hosting the service
                        3. Connect to nearest edge router
                        4. Establish tunnel to service

Controller REST API

The ZT controller exposes a REST API at /edge/client/v1:

EndpointMethodDescription
/authenticatePOSTAuthenticate with JWT or API key
/current-api-sessionGETGet current session info
/servicesGETList available services
/sessionsPOSTCreate a session to a service
/sessionsGETList active sessions
/edge-routersGETList edge routers

All endpoints require a valid ZT session token in the zt-session header.

Security Model

PropertyImplementation
Encryptionx509 mTLS with controller-issued certificates
AuthenticationHanzo IAM JWT + ZT controller ext-jwt
AuthorizationService-level policies managed by controller
IdentityCryptographic identity bound to x509 certificate
Key rotationAutomatic certificate renewal before expiry
NAT traversalUDP hole punching, no open ports required
Zero trustEvery connection authenticated, no trusted networks

Deployment Patterns

Client-to-Service

The most common pattern. A client application dials a service through the ZT fabric:

Client App  ──dial──>  ZT Fabric  ──>  Backend Service

Service Mesh

Multiple services communicate through the ZT fabric without exposing any ports:

Service A  <──>  ZT Fabric  <──>  Service B
                    |
              Service C

Gateway Bridge

The Hanzo API Gateway bridges HTTP traffic to ZT services:

Internet  ──HTTP──>  API Gateway  ──ZT──>  Backend Service

On this page