The tor process will launch the pirserver process, and hold pipes to the pirserver's stdin, stdout, and stderr. All communication between the processes is over those pipes. Anything the pirserver outputs over the stderr pipe should be logged by the tor process. If the pirserver finds its stdin has reached EOF, it should terminate. The general format of request messages (tor -> pirserver) 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 (pirserver -> 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 three request types: PIRSERVER_REQUEST_PARAMS (0x01) Request the current pirserver params data The body_len must be 0. The pirserver will respond with PIRSERVER_RESPONSE_PARAMS. (TODO: do we want to allow for an error response to this request?) PIRSERVER_REQUEST_STORE (0x02) Store an object with a given 32-byte key The body_len must be at least 32. The first 32 bytes of the body are the key under which to store the object, and the remaining bytes are the object. If body_len is exactly 32, it means to remove the object with the specified key. Storing an object with an already-existing key will overwrite the old object with that key. This request does not elicit a response from the pirserver. PIRSERVER_REQUEST_LOOKUP (0x03) Privately look up an object The body_len will depend on the details of the particular private lookup scheme (XPIR, ZeroTrace, trivial, etc.). There are three response types: PIRSERVER_RESPONSE_PARAMS (0xFF) Reply with the current pirserver params data The body is the params data, which will be sent to the client either in an HTTP 200 reply to an explicit params request, or else in a special cell piggybacked on the creation of the directory lookup circuit. The body_len will depend on the details on the particular private lookup scheme. PIRSERVER_RESPONSE_LOOKUP_SUCCESS (0xFE) Response to a successful lookup The body is the result of the private lookup requested by the corresponding PIRSERVER_REQUEST_LOOKUP. The body_len will depend on the details on the particular private lookup scheme. PIRSERVER_RESPONSE_LOOKUP_FAILURE (0xFD) Response to a failed lookup The body_len must be 0.