API Reference
StreamSec.PIR.Double
Private Information Retrieval - DoublePIR
ver.inc turns overflow and range checking off for the whole library, and this
unit repeats that AFTER the include for the reason StreamSec.PIR.Simple does:
the wrap-around of a UInt32 IS the arithmetic here, and a build with overflow
checking on would raise on correct input.
Feature notes: Private information retrieval notes (SimplePIR / DoublePIR)
Classes, interfaces and records
recordtPirDoubleParams
A resolved two-level parameter set. The fields RowCount through Delta mean what they mean in tPirParams, so that a shape can be compared field for field with the one-level scheme; DigitCount is kappa and is the only quantity the second level adds.
SecretDim : Integer;
n
Modulus : Integer;
p
LimbBitLen : Integer;
b = floor(log2 p)
LimbCount : Integer;
d, the number of parallel databases
RowCount : Integer;
l, the height of every database
ColCount : Integer;
m, the width of every database
RecordCount: Integer;
RecordLen : Integer;
octets
Delta : tPirWord;
2^32 div p
DigitCount : Integer;
kappa, the least k with p^k >= q
class function Resolve(aRecordCount, aRecordLen: Integer): tPirDoubleParams; static;
Resolves (p, l, m) from a record count and a record length. Unlike the one-level scheme there is no fixpoint to reach: the shape follows from the record COUNT alone, and the modulus follows from the shape, so the limb width the modulus implies cannot move the shape that chose it. Raises ePirParamsOutOfRange when no row of the modulus table supports the shape at this secret dimension.
class function ForModulus(aModulus, aRecordCount, aRecordLen, aSecretDim: Integer): tPirDoubleParams; static;
The same shape for a modulus and a secret dimension the caller names. Equation (3) is asserted exactly as in Resolve, so a modulus that cannot decode is refused here too.
function CellCount: Int64;
Cells in one database, and in all of them.
function TotalCellCount: Int64;
function SampleCount: Int64;
max(m, l), which is what equation (3) is stated in and what the modulus table is indexed by.
function SecondRowCount: Int64;
kappa*(n+1), the height of the second level's database, and kappa*(n+1)+1, the number of Z_p elements one recovery rounds.
function RecoveryCount: Int64;
function HintLen: Int64;
Octets on the wire. The hint is downloaded once per epoch; it does not grow with the record count, and it grows linearly with the record length.
function QueryLen: Int64;
function AnswerLen: Int64;
Delegates to Int64, passing 1 argument(s), and returns its result.
function CorrectnessHolds: Boolean;
Equation (3) of Theorem E.1, at this shape and this secret dimension.
procedure CheckCorrectness;
Raises ePirParamsOutOfRange unless CorrectnessHolds.
classtDoublePirServer
The server. It holds LimbCount databases uncentred, answers one query with all of them, and computes both levels of hint on the centred form of the same words.
constructor Create(const aParams: tPirDoubleParams; const aSeed1, aSeed2: tBytes);
aSeed1 and aSeed2 are the 16 octets A1 and A2 are expanded from. Both are public - the client needs them to form its query - and they must differ, because Figure 14 samples the two matrices independently.
destructor Destroy; override;
procedure PutRecord(aRecordIndex: Integer; const aRecord: tBytes);
Writes one record: limb k into database k, at the row and column the record index names. A record of the wrong length is refused rather than padded.
Full description »
procedure BuildHint;
Recomputes both levels of hint from the current tables, bumps the version and clears the written mark.
Full description »
procedure Answer(const aQuery: tPirWordArray; aHintVersion: UInt32; const aHintDigest: tBytes; var aAnswer: tPirWordArray);
The answer to one query, from every database. 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: tPirDoubleParams read fParams;
property Seed1: tBytes read fSeed1;
property Seed2: tBytes read fSeed2;
property Table: tPirWordArray read fDb;
The databases as the server holds them: LimbCount blocks of RowCount by ColCount words in [0, p), row-major and uncentred.
A WRITE THROUGH THIS PROPERTY IS NOT MARKED. It reaches the field directly, so Answer's stale-table refusal cannot see it. Writing here is the caller's to keep consistent: rebuild the hint after, or use PutRecord, which marks that it wrote.
property Hint: tPirWordArray read fHintC;
The second level's hint, which is what the client downloads.
property HintDigits: tPirWordArray read fHintS;
The first level's hint in decomposed form, which the client does NOT download: it is the second level's database, and it is here because a caller that persists a prepared server has to persist it.
property HintVersion: UInt32 read GetHintVersion;
property HintDigest: tBytes read GetHintDigest;
The SHA-256 of Hint above - the second level's hint, the one the client downloads - 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 »
classtDoublePirClient
The client. It holds the hint and, between Query and Recover, the two secrets that decode the answer.
constructor Create(const aParams: tPirDoubleParams; const aSeed1, aSeed2: 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, so a client needs nothing only the server could compute in order to check what answered it.
procedure Query(aRecordIndex: Integer; var aQuery: tPirWordArray);
c1 followed by c2, with Delta added to entry aRecordIndex mod ColCount of the first and to entry aRecordIndex div ColCount of the second.
Full description »
procedure QueryFrom(aRecordIndex: Integer; const aSecret1Source, aError1Source, aSecret2Source, aError2Source: iPirOctetSource; var aQuery: tPirWordArray);
The same query from four 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: tPirDoubleParams 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 what Recover compares aHintDigest against. Empty until SetHint.
property PRNG: iRawRandom read GetPRNG write SetPRNG;
The generator the secrets and the errors are drawn from. nil, the default, means the process generator.
Routines