diff --git a/docs/PROTOCOL.md b/docs/PROTOCOL.md index aa104d5..3a257c8 100644 --- a/docs/PROTOCOL.md +++ b/docs/PROTOCOL.md @@ -31,27 +31,37 @@ For detailed analysis of alternative PoW algorithms and comprehensive justificat ## Protocol Flow -### Successful Flow +### Challenge Request Flow ``` Client Server | | |-------- CHALLENGE_REQUEST ------------->| | | |<------- CHALLENGE_RESPONSE -------------| (HMAC-signed) + | | + [Connection closes] +``` + +### Solution Submission Flow +``` +Client Server | | |-------- SOLUTION_REQUEST -------------->| | | |<------- QUOTE_RESPONSE -----------------| (if solution valid) | | + [Connection closes] ``` ### Error Flow ``` Client Server - |-------- CHALLENGE_REQUEST ------------->| - |<------- CHALLENGE_RESPONSE -------------| + | | |-------- SOLUTION_REQUEST (invalid) ---->| + | | |<------- ERROR_RESPONSE -----------------| (if solution invalid) + | | + [Connection closes] ``` ## Message Format @@ -252,12 +262,21 @@ Server verifies solutions through the following steps: ## Connection Management ### Connection Lifecycle + +The protocol uses separate TCP connections for challenge requests and solution submissions: + +#### Challenge Request: 1. **Connect**: Client establishes TCP connection to server -2. **Challenge**: Client requests and receives HMAC-signed challenge -3. **Solve**: Client solves PoW challenge offline (can take time) -4. **Submit**: Client submits solution with challenge proof -5. **Receive**: Client receives quote (if valid) or error (if invalid) -6. **Disconnect**: Connection closes automatically after response +2. **Request**: Client sends CHALLENGE_REQUEST +3. **Receive**: Client receives CHALLENGE_RESPONSE with HMAC-signed challenge +4. **Disconnect**: Connection closes automatically + +#### Solution Submission: +1. **Solve**: Client solves PoW challenge offline +2. **Connect**: Client establishes new TCP connection to server +3. **Submit**: Client sends SOLUTION_REQUEST with challenge and nonce +4. **Receive**: Client receives QUOTE_RESPONSE or ERROR_RESPONSE +5. **Disconnect**: Connection closes automatically ### Timeouts and Limits