methodtSimplePirClient.Recover
function Recover(const aAnswer: tPirWordArray; aHintVersion: UInt32; const aHintDigest: tBytes): tBytes;
The record, from the answer to the query this client last made.
aHintDigest is what the answering server's HintDigest read, shipped beside aHintVersion. It is compared against the digest this client derived from its own hint at SetHint, so the comparison is between two things the client can see.
WHAT IT REFUSES, AND EVERY CLASS IS PINNED TO ITSELF. Raises ePirError when there is no outstanding query, which is 'a client cannot recover without having made a query'; ePirDimensionMismatch when there is no hint or the answer is not RowCount words, which are 'a client cannot recover without a hint' and 'an answer of the wrong length is refused'; ePirHintVersionMismatch when aHintVersion is not the version this client was given, which is 'an answer at a hint version this client was not given is refused'; and ePirHintMismatch when aHintDigest is not the digest over the hint this client holds, which is 'the second server's answer is refused against the first's hint, at a version that matches'. THAT IS ALL. Each is pinned to the class ITSELF and not to a base it descends from, because the first of them IS the base: ePirDimensionMismatch descends from ePirError, so a handler written for the leaves lets the no-query case past it - and that is the case a caller reaches by accident, because Recover's decode block clears the state that decoded the answer, so a second call raises once one has got that far. After a Recover that REFUSED it does not, because all five checks are made before that block: the query stands, and a call that carries the remedy - the version the answer was computed at, the stamp that goes with it, a hint, an answer of the right length - decodes it on that same query. A call that repeats the arguments that were refused is refused again, with the same class. What stands is the query, not the exchange.
THE DIGEST IS WHAT BINDS AN ANSWER TO A HINT, AND THE VERSION NEVER DID. The version is a counter one server moves when it recomputes a hint: two servers over different tables are both at version 1 until one of them does, and a client handed the wrong server's answer at a matching version used to decode it and return wrong octets. It is refused now, and every one of eight indices is refused rather than one of them - 'and not one of eight lookups against another table's answer returns a record: every one of the eight is refused'. The same guard covers a hint the client patched that the server did not, whatever the version says: 'a stale hint whose version matches is refused, because the digest over it is not the digest over the hint the answer was computed against'.
WHAT THE DIGEST CANNOT DO, said because a reader will otherwise assume it. It travels beside the answer, not inside it, and nothing here authenticates either: whoever can hand this client an answer can hand it a stamp to go with it. It separates one hint from another; it does not separate an honest server from a dishonest one. A deployment that needs the second authenticates the RECORD, above this unit.
The case a digest cannot reach at all - a server that writes a record and answers without recomputing - is refused by the SERVER, at Answer, and is ePirHintStale rather than anything on this list.
AN HONEST SERVER NOW REFUSES TWO OF THESE FIRST, and NOTHING HERE WAS REMOVED FOR IT. Answer takes the client's hint version and stamp, so against a server that runs this library the version and digest cases are raised there, before the table is read, and reach this client as the same two classes out of Answer rather than out of Recover. That is an optimisation on the server's work and not a check moved: a server that does not make it, or lies about the result of making it, is exactly the server this comparison exists for. Both are made here, on every call, on values this client can see.
A recovery that is merely wrong yields wrong octets, never an exception.