The tor process will launch the pirclient process, and hold pipes to the pirclient's stdin, stdout, and stderr. All communication between the processes is over those pipes. Anything the pirclient outputs over the stderr pipe should be logged by the tor process. If the pirclient finds its stdin has reached EOF, it should terminate. The general format of request messages (tor -> pirclient) is: request_id: 8 bytes request_type: 1 byte body_len: 4 bytes (big-endian unsigned int) body: (body_len) bytes The general format of response messages (pirclient -> tor) is: request_id: 8 bytes (must match the request_id being responded to) response_type: 1 byte body_len: 4 bytes (big-endian unsigned int) body: (body_len) bytes There are two request types: PIRCLIENT_REQUEST_CREATE (0x41) Request the creation of a private query The body_len must be at least 32. The first 32 bytes of the body are the plaintext query, and the remaining bytes are the current pirserver params for the server we're going to send this query to. PIRCLIENT_REQUEST_EXTRACT (0x42) Extract the plaintext data from a PIR response The body_len must be at least 8. The first 8 bytes of the body are the Query ID returned in the PIRCLIENT_RESPONSE_CREATE message, and the remaining bytes are the PIR response. Any given Query ID must be used in at most one PIRCLIENT_REQUEST_EXTRACT message (and it should be exactly one). There are two response types: PIRCLIENT_RESPONSE_CREATE (0xBF) Reply with a PIR query The body begins with an 8-byte Query ID (which the tor process should hold on to, to match it to the corresponding PIR response in the PIRCLIENT_REQUEST_EXTRACT message). The remainder of the body is the PIR query to send to the server. A body_len of 0 indicates an error. PIRCLIENT_RESPONSE_EXTRACT (0xBE) Reply with the plaintext data extracted from a PIR response The body is the plaintext of the response received from the PIR server. A body_len of 0 indicates an error.