Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.PIR.Simple

ver.inc turns overflow and range checking off for the whole library, and this
  unit repeats that AFTER the include so that the setting cannot be inherited
  by accident: the wrap-around of a UInt32 IS the arithmetic here, and a build
  with overflow checking on would raise on correct input. The Boolean
  evaluation setting matches the kernel's for the same reason it is set there:
  and/or over Booleans is evaluated with branches, so the one comparison that
  must not branch - PirGaussGE, against a threshold derived from the client's
  secret - is written in integer arithmetic and never as a Boolean
  expression.

Feature notes: Private information retrieval notes (SimplePIR / DoublePIR)

Classes, interfaces and records

classePirParamsOutOfRange

inherits from ePirError

A parameter set that no table row supports, a dimension outside the scheme's range, or a chosen (p, L, M) that fails the correctness inequality.

(no public members)

classePirDimensionMismatch

inherits from ePirError

An array whose length contradicts the parameter set it is used with.

(no public members)

classePirHintVersionMismatch

inherits from ePirError

A hint version other than the one the exchange's other side holds. It is a statement about that COUNTER alone: what binds an answer to the hint it was computed against is the digest below, and the two are separate classes because the remedies differ.

RAISED FROM BOTH SIDES, over the same two counters. tSimplePirClient.Recover and tDoublePirClient.Recover raise it when the version an answer is stamped with is not the client's; tSimplePirServer.Answer and tDoublePirServer.Answer raise it when the version a QUERY names is not the server's, which is the same disagreement caught one round trip earlier and before the table is read. Either way the remedy is the same - fetch the answering server's current hint - which is why it is one class and not two.

(no public members)

classePirHintMismatch

inherits from ePirError

A hint digest other than the one the exchange's other side computed from the hint it holds. Raised by tSimplePirClient.Recover and by tDoublePirClient.Recover over the stamp beside an ANSWER, and by tSimplePirServer.Answer and tDoublePirServer.Answer over the stamp a QUERY carries - the same comparison, made at whichever end has both values first.

WHY THIS AND NOT ePirHintVersionMismatch, which is the neighbour a reader reaches for. The version says one side is BEHIND the other and fetching the answering server's current hint fixes it. This one says the two are looking at a different hint altogether - another shard's table, or a hint one side patched and the other did not - and fetching a hint from whoever answered would not repair the exchange, it would hide it. A handler that retries on a version mismatch must not retry on this one, so it is a sibling of that class and not a descendant of it.

WHY NOT ePirDimensionMismatch: nothing here has the wrong length. The answer, the hint and the parameter set all agree on every dimension, and that is what makes the case worth a class of its own.

(no public members)

classePirHintStale

inherits from ePirError

An Answer asked of a server whose table has been written since its hint was last computed. Raised by tSimplePirServer.Answer and tDoublePirServer.Answer - by the SERVER, on its own state, before any answer exists.

IT NAMES THE HINT AND NOT THE TABLE because the hint is the thing that has gone wrong: the table is exactly what the caller meant to write, and the remedy is BuildHint - or, in this unit, UpdateHintRow over every row the write moved. It is not ePirHintVersionMismatch, although Answer now makes that comparison too: a write to the table moves no counter and releases no hint, so the version a query names is still the server's own and the digest a query carries still matches - this case is exactly the one where both of those agree and the answer would STILL be wrong, which is why the mark exists at all. It is not ePirDimensionMismatch either, because no array here is the wrong length.

(no public members)

recordtPirModulusRow

One row of the plaintext-modulus table. LogSampleCount is the row's index: the row that applies is the first whose 2^LogSampleCount is at least the sample count of the shape. Delta, HalfDelta and Slack are 2^32 div p, its half, and 2^32 - Delta*p; they are shipped rather than computed so that a transcription error shows up as a failed assertion at unit start rather than as a scheme that decodes wrongly.

LogSampleCount: Integer; SimpleModulus : Integer; DoubleModulus : Integer; Delta : tPirWord; HalfDelta : tPirWord; Slack : tPirWord; LimbBitLen : Integer;

recordtPirParams

A resolved parameter set: the plaintext modulus, the matrix shape it implies, and the record layout that fills it. Every array in the system is shaped by RowCount and ColCount, so these are resolved once and carried.

SecretDim : Integer;
n
Modulus : Integer;
p
LimbBitLen : Integer;
b = floor(log2 p)
LimbCount : Integer;
Ne, Z_p limbs per record
RowCount : Integer;
L, the height of db and the length of an answer
ColCount : Integer;
M, the width of db and the length of a query
RecordCount: Integer; RecordLen : Integer;
octets
Delta : tPirWord;
2^32 div p
class function Resolve(aRecordCount, aRecordLen: Integer): tPirParams; static;
Resolves (p, L, M) from a record count and a record length by the fixpoint of the modulus table, then asserts the correctness inequality for what it chose. Raises ePirParamsOutOfRange when no row supports the shape or when the inequality fails.
class function ForModulus(aModulus, aRecordCount, aRecordLen, aSecretDim: Integer): tPirParams; static;
The same shape for a modulus and a secret dimension the caller names. The correctness inequality is asserted exactly as in Resolve, so a modulus that cannot decode is refused here too.
function CellCount: Int64;
RowCount*ColCount, in a type that holds it.
function SampleCount: Int64;
The sample count the modulus table is indexed by: ceil(sqrt(L*M)). The noise the client must round away is a sum of this many terms.
function HintLen: Int64;
Octets on the wire. The hint is downloaded once per epoch, the query and the answer once per lookup.
function QueryLen: Int64;
Delegates to Int64, passing 1 argument(s), and returns its result.
function AnswerLen: Int64;
Delegates to Int64, passing 1 argument(s), and returns its result.
function CorrectnessHolds: Boolean;
True when floor(q/p) >= sqrt(2)*sigma*p*sqrt(SampleCount)*sqrt(ln(2/delta)), the inequality that carries the correctness claim.
procedure CheckCorrectness;
Raises ePirParamsOutOfRange unless CorrectnessHolds.

interfaceiPirOctetSource

An octet stream. The matrix expander and the library's random generator both present one, so the error sampler does not know which it is drawing from.

procedure NextOctets(var aBuf; aByteLen: Integer);

interfaceiPirMatrixExpander

inherits from iPirOctetSource

The public matrix, as a stream rather than a matrix. The client must use it this way: materialising A costs M*n*4 octets.

procedure Reset;
Returns the stream to its first block.
procedure NextWords(var aBuf: tPirWordArray; aOffset, aWordCount: Integer);
Fills aWordCount words of aBuf from aOffset with the next words of the stream: little-endian, in stream order. A call for a whole multiple of the row length yields that many complete rows.

classtPirGauss

The discrete Gaussian of the scheme, sigma = 6.4, as two's-complement UInt32 residues. Constant time: every sample scans all cPirGaussTau thresholds and applies its sign unconditionally.

constructor Create(const aSource: iPirOctetSource); function Sample: tPirWord;
One sample, consuming exactly 16 octets of the source.
procedure Fill(var aVector: tPirWordArray; aOffset, aCount: Integer);
aCount samples into aVector from aOffset, in stream order.

classtSimplePirServer

The server. It holds the table uncentred, answers queries with it, and computes the hint on the centred form of the same words.

constructor Create(const aParams: tPirParams; const aSeed: tBytes);
aSeed is the 16 octets A is expanded from. It is public: the client needs it to form its query.
destructor Destroy; override; procedure PutRecord(aRecordIndex: Integer; const aRecord: tBytes);
Writes one record into its column and its block of rows. A record whose length is not exactly RecordLen is refused: a short one is not padded and a long one is not truncated, because a caller that pads or overruns by accident gets a record back that it did not store. Full description »
procedure BuildHint;
Recomputes the whole hint from the current table, bumps the version and clears every row mark. Cost is RowCount*ColCount*SecretDim multiply-adds, n times one query. Full description »
procedure UpdateHintRow(aRowIndex: Integer);
Recomputes one row of the hint, bumps the version and clears THAT ROW's mark, which is what lets a changed record be pushed to a client that already holds a hint. Full description »
procedure GetHintRow(aRowIndex: Integer; var aRow: tPirWordArray);
The n words of one hint row, which is what UpdateHintRow ships.
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. Full description »
property Params: tPirParams read fParams; property Seed: tBytes read fSeed; property Table: tPirWordArray read fDb;
The table as the server holds it: RowCount by ColCount words in [0, p), row-major and uncentred. It is what a server persists between runs, and it is not secret from the client. Full description »
property Hint: tPirWordArray read fHint; property HintVersion: UInt32 read GetHintVersion; property HintDigest: tBytes read GetHintDigest;
The SHA-256 of the hint above, which a caller ships beside the answer exactly as it ships HintVersion - and which a client ships back, as the stamp Answer takes. Full description »

classtSimplePirClient

The client. It holds the hint and, between Query and Recover, the secret that decodes the answer.

constructor Create(const aParams: tPirParams; const aSeed: tBytes); destructor Destroy; override; procedure SetHint(const aHint: tPirWordArray; aHintVersion: UInt32);
Takes the epoch's hint and the version it was computed at. The digest Recover compares is DERIVED HERE, from the octets handed in, and is not a second thing the caller supplies: a client can check what it holds against what answered it without being told anything only the server could compute.
procedure ReplaceHintRow(aRowIndex: Integer; const aRow: tPirWordArray; aHintVersion: UInt32);
Replaces one row of the hint with what the server recomputed for it, and re-derives the digest over the hint the replacement leaves.
procedure Query(aRecordIndex: Integer; var aQuery: tPirWordArray);
qu := A*s + e with Delta added to entry aRecordIndex mod M. The secret and the query sum are kept until a Recover that DECODES, and wiped by that one. A Recover that refuses leaves them standing, on purpose: it is what lets a caller take the remedy for a version mismatch on the same query rather than starting a new one.
procedure QueryFrom(aRecordIndex: Integer; const aSecretSource, aErrorSource: iPirOctetSource; var aQuery: tPirWordArray);
The same query from two named octet sources instead of the library's generator, so that a test can reproduce one. No octet the server sees depends on whether a deployment drew from these or from the generator.
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. Full description »
property Params: tPirParams read fParams; property HintVersion: UInt32 read fHintVersion; property HintDigest: tBytes read GetHintDigest;
The SHA-256 this client derived from the hint it holds, which is the value Recover compares aHintDigest against. Empty until SetHint.
property PRNG: iRawRandom read GetPRNG write SetPRNG;
The generator the secret and the error are drawn from. nil, the default, means the process generator.

Types (enumerations, sets, aliases)

arraytPirGaussThreshold

A cumulative-distribution threshold, little-endian limbs: index 0 is least significant. UInt32 rather than UInt64 because the comparison against it must be branch-free on Win32 too, and Win32 has no 64-bit compare instruction.

  tPirGaussThreshold = array [0..3] of UInt32;

Routines