Client Handshake Flow Specification
Overview
This document defines the handshake flow implementation specification for ATH protocol clients (agents).Client Responsibilities
- Manage its own DID identity and public/private key pairs
- Store and manage user authorization credentials
- Initiate handshake requests and complete mutual identity verification
- Negotiate access permissions and obtain access tokens
- Maintain encrypted communication sessions with the server
Complete Handshake Flow (Client Perspective)
Prerequisite: Obtain User Pre-Authorization
Before initiating a handshake, the client must first obtain a pre-authorization credential from the user:- Request authorization from the user, specifying the scope of resources to be accessed
- The user signs an authorization credential containing the authorization scope, validity period, and other information
- The client securely stores the user authorization credential
Step 1: Initiate Handshake Request
The client sends a handshake request message to the server:Step 2: Process Server Handshake Response
After receiving the server response, the client:- Verifies the validity of the server DID and public key
- Verifies the server’s signature of nonce A is correct
- Negotiates and determines the protocol version and encryption algorithm
- Saves the server public key and metadata
Step 3: Send Identity Proof
The client signs nonce B generated by the server using its own private key and sends an identity proof message:Step 4: Process Identity Verification Result
The client receives the identity verification result:- Checks whether identity verification passed
- Reads the list of supported scopes and configuration information from the server
- If verification fails, terminates the handshake flow
Step 5: Send Permission Request
The client sends a permission request to the server, attaching the user pre-authorization credential:Steps 6-7: Wait for User Authorization Confirmation
The client waits for the server to complete the user authorization confirmation flow. This process involves direct interaction between the server and the user; the client does not need to participate.Step 8: Process Permission Approval Result
The client receives the permission approval result:- Checks whether the granted permission scope meets its requirements
- Records access restrictions and validity period
- If permissions are denied, terminates the handshake flow
Step 9: Complete Handshake, Establish Session
The client and server complete key negotiation:- Generates key exchange parameters and sends them to the server
- Receives the server’s key exchange parameters and generates a shared session key
- Verifies the validity of the access token issued by the server
- Encrypts all subsequent business requests using the session key
Error Handling
| Error Code | Description | Handling |
|---|---|---|
| 401 | Identity verification failed | Check identity configuration and re-initiate handshake |
| 403 | Permission denied | Prompt the user to re-authorize and adjust the permission scope |
| 408 | Handshake timeout | Retry the handshake flow, up to 3 retries |
Security Requirements
- User authorization credentials must be stored encrypted to prevent leakage
- Private keys must be stored securely and must not be transmitted in plaintext
- Session keys must be rotated periodically, with a validity period not exceeding 24 hours