vfhe.piop.relations

The relation toolbox (piop.md section 4).

class vfhe.piop.relations.FamilyShape(widths: Mapping[str, int | tuple[int, ...]])

The shape of a family of sparse tables packed into one master oracle.

widths maps each sparse index field of the inner relation to the width (number of variables) of the table it holds, or to the tuple of widths of the tables it holds; the slots are those tables in that order, a of them. The master P is an oracle over selectors + xs: ceil(log2 a) slot variables T (none for a single slot) followed by max width table variables X, with the index bits of a nonzero i || k read LSB-first – slot i in the low bits, the table’s own index k above them (index_of). Member i is the restriction of P at T = bin(i) (bit j of i at T_j), the coordinates of X past its width fixed to 0, the rest renamed to variables of its own.

The shape sits in the index of the dense relation, as data (not an Oracle, so Relation.index_oracles does not take it for one), and digest() is by the widths.

classmethod of(index: Mapping, fields: tuple[str, ...]) → FamilyShape

The shape of the tables an index holds in its sparse fields.

property count: int

The number of slots, a.

implicit() → ImplicitOracle

A fresh handle for the master, over selectors + xs.

slot_bits(i: int) → dict

T = bin(i): the slot variables fixed to the bits of i.

index_of(i: int, k: int) → int

The master’s index of entry k of the table in slot i.

restriction(P, i: int) → VirtualOracle

Member i of the family as a restriction of P (the master’s handle, or its table): T = bin(i), the coordinates of X past the slot’s width fixed to 0, the rest renamed to variables of its own.

place(P) → dict

The sparse index fields filled with the restrictions of P, in the shape of the family: one restriction, or a tuple of them.

class vfhe.piop.relations.Relation_Circuit(index=None)

Circuit satisfiability with the wiring predicates committed through one dense index oracle: Relation_CircuitSparseIndex with its "predicates" replaced by ("dense", "shape", "speval"), the index ("circuit", "dense", "shape", "speval"); oracles = (out, w_in) and the head out as there. The decider decodes the predicates once through the realization and decides the sparse-index relation; compute_head is its (the output table from the input through the circuit). Its protocol is compose(dense_layering), registered against this class and its Start: GKR runs in the first layer over restrictions of the master, the realization’s protocol in the second (protocols/sparse.py).

Start

alias of Start

compute_head(statement: Statement)

The head’s table from the statement’s other oracles (prover view).

decode()

The master’s sparse table, as the realization decodes it from the dense index oracle.

inner

alias of Relation_CircuitSparseIndex

start(statement: Statement, claims: list[Statement]) → Statement

The started statement: statement (headed) with the evaluation claims on its head, as a statement of Start.

class vfhe.piop.relations.Relation_CircuitSparseIndex(index=None)

The input oracle evaluates, under the circuit in the index, to the output oracle: oracles = (out, w_in), out a table over s_out variables (public, committed, or plain, or the implicit head of a headed statement) and w_in one over s_in variables. The index is the circuit description and its wiring predicates, ("circuit", "predicates"), the latter the tuple wiring_predicates builds – the sparse index field, public tables or restrictions of a master – which GKR’s layer bodies read; indexed(circuit, domain) is the indexer. The ideal decider evaluates the circuit gate by gate over the input table; compute_head returns its output table, so a circuit can define an implicit oracle of a larger reduction.

classmethod indexed(circuit: gkr.Circuit, domain)

The relation indexed by circuit, its predicates built in domain (a Ring, a Field, or None for plain Python values).

property circuit: gkr.Circuit

The circuit this relation is indexed by.

property predicates: tuple[TableOracle, ...]

The wiring predicates, (lin_0, xmult_0, ..., lin_{d-1}, xmult_{d-1}).

layer_tables(table) → list

Every layer’s padded wire values from the input table (a dense table): entry 0 is the input, entry l + 1 the gates of layer l (zeros past the last gate).

compute_head(statement: Statement)

The head’s table from the statement’s other oracles (prover view).

Start

alias of Start

start(statement: Statement, claims: list[Statement]) → Statement

The started statement: statement (headed) with the evaluation claims on its head, as a statement of Start.

class vfhe.piop.relations.Relation_Equal(index=None)

Two oracles over the same number of variables agree on the hypercube, oracles = (a, b): the headless statement that ties a circuit’s output oracle to its output layer.

class vfhe.piop.relations.Relation_Layer(index=None)

Gate layer l of a circuit as a sum definition, indexed by ("circuit", "layer", "lin", "xmult"), the circuit, l and the layer’s two sparse predicates: oracles = (W_{l+1}, G_l) with G_l the layer identity over those predicates and the layer below under two renamings (GKR builds it). compute_head evaluates the gates on the table of the layer below, linear in the wires, where the generic route would materialize the predicates.

compute_head(statement: Statement)

L’s table, the hypercube sums of G over the summed variables, from G’s constituent tables (the prover view): the generic, exponential route. A relation that knows G’s structure (a circuit layer) computes the table directly instead.

Start

alias of Start

start(statement: Statement, claims: list[Statement]) → Statement

The started statement: statement (headed) with the evaluation claims on its head, as a statement of Start.

class vfhe.piop.relations.Relation_Lookup(beta: int)

f(b) in t_beta for every b in {0,1}^n, with t_beta = {0, ..., beta - 1} the relation’s index.

The table is an index rather than an instance field because it is the large, reusable, preprocessable part of the claim: one beta serves every lookup of a given digit width, and it is public data both parties hold (piop.md §3).

property beta: int

The table size; t_beta is {0, ..., beta - 1}.

check(statement: Statement) → bool

The ideal decider: every hypercube evaluation is in range.

A dense table in the evaluation basis already is the list of those evaluations, so it is read directly; anything else (a coefficient basis, a defined oracle) is enumerated the slow way.

class vfhe.piop.relations.Relation_Range(bound: int)

Every Z_q coefficient of every hypercube evaluation of the R_q oracle lies in [0, B), the coefficients read as their representatives in [0, q): the range relation on packed polynomials of [CCCFGS25; CCCFGS26]. The index is the bound B.

class vfhe.piop.relations.Relation_ResidueRange(bound: int)

Every entry of an integer table lies in [0, B), the table given by its residues modulo the primes p_1, ..., p_U of q: one oracle per prime, over a field of characteristic p_i (F_(p_i) or an extension of it), whose entries are the residues as elements of the prime subfield. The index is the bound B.

This is Relation_Range on the unpacked table u = unpack(v) of [CCCFGS26] – the multilinear extension of the coefficients of v’s values, one entry per Z_q coefficient – written in residue number system form [Gar59], the CRT components of Z_q: the relation of a range proof whose coefficient oracles are committed per prime instead of as one R_q oracle. An integer below q is determined by its residues (the Chinese remainder theorem), so the claim is that the residue tuple at every hypercube point is that of an integer below B; an entry outside the prime subfield (F_(p^d), d > 1) is the residue of no integer.

class vfhe.piop.relations.Relation_SpEval(index=None)

The sparse-evaluation relation: the sparse oracle "sparse" (P, the head) is what the dense index oracle "dense" (P_dense) encodes, for a family of the given "shape"; no instance fields.

Abstract: the decoding is compute_head, which a realization supplies. A realization subclasses this relation, implements compute_head (the sparse table over the head’s variables, from the dense table and the shape), holds any parameter of its own as a class attribute – the dense layering builds it over the three index fields and nothing else – is decorated with with_start itself (the registry keys on the exact class), and registers against its Start a sequentially composable protocol: one that takes any claims on P, never queries P, draws every challenge itself, and ends in evaluation claims on P_dense – carried in oracles, so that the driver bundles them for the commitment scheme, or terminal when P_dense is a plain table of the ideal model. The generic decider compares the nonzeros of the "sparse" entry, a table in the ideal model, with those of the decoding.

compute_head(statement: Statement)

The decoding: P’s sparse table from P_dense and the shape.

class vfhe.piop.relations.Relation_Sum(index=None)

sum_{b in {0,1}^n} f(b) == value, for a single oracle f.

class vfhe.piop.relations.Relation_SumDef(index=None)

L(z) = sum_{b in {0,1}^m} G(z, b) on the hypercube: a sum definition of the oracle L, the head, by the virtual oracle G over L’s variables z and the summed variables b, the others of G, in G’s order: a layer of a layered circuit in terms of the layer below it [Tha22, §4.6], a grand-product level [Tha13, §5.3.1]. A statement headed at L is how an oracle that is defined and never committed enters a layered reduction: it sits in the layer of L, and SumDefStart, registered against Relation_SumDef.Start, is its composable protocol.

static summed_of(L, G) → list

The summed variables: G’s that are not L’s.

static definition(statement: Statement) → tuple[Oracle, VirtualOracle]

The head L and the defining virtual oracle G of a sum-definition statement, G’s type checked.

compute_head(statement: Statement)

L’s table, the hypercube sums of G over the summed variables, from G’s constituent tables (the prover view): the generic, exponential route. A relation that knows G’s structure (a circuit layer) computes the table directly instead.

Start

alias of Start

start(statement: Statement, claims: list[Statement]) → Statement

The started statement: statement (headed) with the evaluation claims on its head, as a statement of Start.

class vfhe.piop.relations.Relation_SumProd(index=None)

sum_{b in {0,1}^n} prod_j f_j(b) == value, for oracles f_1..f_k over the same variables (an instance whose oracles disagree on them is not in the relation).

class vfhe.piop.relations.Relation_Zero(index=None)

f(b) == 0 for every b in {0,1}^n, for a single oracle f.

vfhe.piop.relations.dense_relation(inner_cls: type[Relation]) → type[Relation]

The relation with a dense index derived from inner_cls, a relation whose index holds a family of sparse tables in the fields it declares as sparse_index_fields: the same instance fields and head, the index fields of inner_cls that are not sparse, then "dense" (P_dense, a table), "shape" (a FamilyShape) and "speval" (the realization, a Relation_SpEval subclass). Its decider decodes once through the realization and decides inner_cls with the slices in the sparse fields’ place; compute_head is inner_cls’s, over the index with the sparse fields holding restrictions of the master’s handle (the head of a relation does not depend on its sparse index oracles). The class is returned undecorated: apply with_start when inner_cls has a head.

vfhe.piop.relations.wiring_predicates(circuit: gkr.Circuit, domain) → tuple[TableOracle, ...]

The indexer’s predicates of circuit in domain: the tuple (lin_0, xmult_0, ..., lin_{d-1}, xmult_{d-1}), public sparse tables, those of layer l over variables [y..., x..., z...] of their own, created here (s_in of y and of x, s_out of z).