methodtSimplePirServer.Answer
procedure Answer(const aQuery: tPirWordArray; aHintVersion: UInt32; const aHintDigest: tBytes; var aAnswer: tPirWordArray);
ans := db_s * qu. The only thing that happens per lookup, and it touches every octet of the table.
aHintVersion and aHintDigest ARE THE CLIENT'S, not this server's: they name the hint the query was formed against, and they are what the client's own HintVersion and HintDigest read. They are here so that a query whose answer the client would refuse is refused BEFORE the table is read. The scan is the whole cost of a lookup - measured at 6.9 ms over the 208.8 MB table of a 7,168-record shard, 24.0 ms at 25,000 records and 101.7 ms at 100,000, and 3.6 to 3.7 times those figures on a host without AVX2, where the first two measured 25.2 ms and 89.6 ms - and the two comparisons that replace it cost 3.9 ns, so a refused request costs the server 1.8 to 26 million times less than it did. The wire pays 36 octets on a query of 28.0 kB or more.
IT COMPUTES NOTHING BUT THE ANSWER, and that is a statement about WRITES: it reads the parameters, the table, the mark count, the version and the stamp, and it assigns to none of them. Before the digest was sealed at UpdateHintRow that was not true: the first Answer after a completed row push took a SHA-256 over the whole hint and stored it, measured at 161,538 us against 51 us for the next call at the 10,923-row shape - and two threads storing a tBytes in one field is a reference-count race, not a hash taken twice. What a deployment may assume from it is in the note on HintDigest below.
IT REFUSES, with ePirDimensionMismatch, when no hint has been built at all, because an answer computed then is one Recover refuses for want of a hint. It is the refusal tDoublePirServer.Answer has always made, on the same class, and a server that answered before BuildHint was spending a whole scan on an exchange that could not end.
IT REFUSES, with ePirHintStale, in two states of its own hint. The first, and the one a caller meets, is while any row written through PutRecord since the hint was last computed is still outstanding - and only those. A write through the Table property marks nothing, so it never puts a row outstanding and never causes a refusal of its own; what it equally cannot do is LIFT one, so a Table write standing beside some PutRecord's mark is refused along with it. Within that bound the check is what makes an answer a statement about the table the client's hint describes, and it is a SERVER-side check on server-side state: no client can make it, and no digest can stand in for it, because a write that nothing followed leaves the hint byte for byte what the client holds.
The second is a hint that carries no stamp, which no call that returned can leave behind - BuildHint and UpdateHintRow both seal - and which a BuildHint that RAISED before it sealed can. It is refused rather than stamped here, because taking the digest would be a write on the serving path and the hint it would be over is a hint the call never finished.
IT REFUSES, with ePirHintVersionMismatch, when aHintVersion is not this server's, and with ePirHintMismatch when aHintDigest is not the stamp over the hint this server holds. THEY ARE THE CLIENT'S OWN CLASSES, the ones Recover would have raised on the same disagreement one round trip later, because they are the same disagreement and carry the same remedy - and a caller that already handles them handles these unchanged. The stale refusal is kept AHEAD of both: a table written since the hint was built leaves the version and the digest agreeing, so a client sent to refresh its hint by a version refusal would fetch a hint its next query was refused against anyway.
THIS DOES NOT WEAKEN THE CLIENT'S CHECK AND CANNOT REPLACE IT. It is an optimisation for an HONEST server: a dishonest one can answer anything and stamp it anything, so Recover still makes both comparisons itself and nothing on the client was removed for this. What is refused here is work, not trust.
A CLIENT THAT DECLINES TO NAME ITS HINT - an empty aHintDigest - IS SERVED, at the cost of the scan, by a server that has a hint to answer against: 'and a completed push still answers a query that names no hint at all'. The refusals above are about the server's OWN state and are made whatever the client named, so a server with no hint refuses this client too, and that is the only way an unidentified query is now refused; aHintVersion is then not read either, because the two travel together and a version without a stamp is a number the server has no way to place. That is not a gap left open by oversight: the server refuses what it KNOWS will fail, and about an unidentified query it knows nothing. A deployment that wants identification to be mandatory refuses the empty stamp itself, before the call; the library does not make that policy for it.