[PHASE-7] Update the protocol

This commit is contained in:
Savely Krendelhoff 2025-08-23 13:24:31 +07:00
parent 65945d34c0
commit e9f60136ef
No known key found for this signature in database
GPG key ID: F70DFD34F40238DE

View file

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