vfhe.piop.protocols

The protocols (piop.md section 5): the reductions registered against the relations of the toolbox. The sumcheck protocols are a subpackage, sumcheck, with their round-message kernels (sumcheck.rounds) and the prover’s forms of a virtual oracle (sumcheck.prover_view).

class vfhe.piop.protocols.GKR

Relation_CircuitSparseIndex as a layered reduction: the output test in L_0, then the gate layers from the output layer down, one Relation_Layer statement per layer headed at the layer’s implicit oracle; the input oracle is w_in itself. Registered protocols it relies on: OutputTest for Relation_Equal, SumDefStart for Relation_Layer.Start, the sumcheck and VirtualEval.

reduces_from

alias of Relation_CircuitSparseIndex

soundness_error(statement: Statement, domain: Any = None) → float | None

The output test’s own error; the layers’ is the sumchecks’. The domain defaults to the output oracle’s (Oracle.domain).

layers(root: Statement, iop: IOP) → list[list[Statement]]

The layered reduction of root.

class vfhe.piop.protocols.GKR_Start

The sequentially composable form of GKR, for Relation_CircuitSparseIndex.Start: the gate layers alone, the top one started by the claims the statement carries on its head, the output oracle.

reduces_from

alias of Start

soundness_error(statement: Statement, domain: Any = None) → float | None

No random evaluation of its own: the layers’ errors only.

layers(root: Statement, iop: IOP) → list[list[Statement]]

The layered reduction of root.

class vfhe.piop.protocols.LogUpGKR(field: Any, messages: OracleMessages | None = None)

Relation_Lookup -> Relation_Eval: the lookup argument of [Hab22] with its fractional sums proven by GKR [PH23].

Over a field of characteristic above the number of looked-up entries, every entry of f (over n variables) lies in t_beta exactly when, for some m,

sum_(x in {0,1}^n) 1 / (X - f(x)) = sum_(y < beta) m(y) / (X - y),

m(y) then being the number of entries equal to y (the set-inclusion lemma of [Hab22]). The prover sends m, the verifier draws xi outside t_beta, and the two sides at X = xi are the roots of two trees of fractions (fraction_tree): (1, xi - f) over 2^n leaves and (m, xi - t) over beta. The two trees have their own depths, and the verifier compares the roots as fractions, a_f h_t == a_t h_f with h_f != 0.

Each root is proven by GKR from the root down [PH23, §3]: a claim (y, y') on layer k at the point rho is, by the layer rule,

y + lambda y’ = sum_(x in {0,1}^k) eq~(rho, x) [a(x,0) h(x,1)
  • a(x,1) h(x,0) + lambda h(x,0) h(x,1)]

over layer k + 1, a sum of degree 3 in each variable, proven by the registered Relation_Sum protocol. The prover then sends the four values a(r,0), a(r,1), h(r,0), h(r,1) at the sumcheck’s point r, the verifier checks them against the sumcheck’s final claim, draws psi and takes the line through them to the claim on layer k + 1 at (r, psi). On the leaves, that claim is one evaluation claim on f (f = xi - h) or on m (m = a); the verifier evaluates the table’s t~(y) = sum_k 2^k y_k itself.

The driver hands the protocol every frontier claim at once, and one run proves all of them. Claims into the same t_beta share one m, the sum of their counts, and one table-side tree; among them, claims on oracles with the same number of variables are concatenated into one oracle-side tree, as in Lookup (s = ceil(log2 k) selector variables after the data ones, zero blocks as padding, counted in m), and the verifier adds the roots of the oracle-side trees of one table before comparing. Every tree of the run, whatever its table and depth, shares xi and the points: layer k of all the trees deeper than k is one sumcheck, the trees’ claims combined by independent challenges. The run has max depth * (max depth - 1) / 2 sumcheck rounds.

reduces_from

alias of Relation_Lookup

parameters() → tuple

The public parameters of this protocol, in a fixed order; empty by default.

soundness_error(statement: Statement, domain: Any = None) → float | None

(2^(n + 1) + beta) / (|A| - beta), twice the entries of a claim on an oracle over n variables, with |A| the size of the exceptional set the challenges are drawn from.

The draw of xi is where a false claim can pass: the difference of its two sides, a rational function, has a numerator of degree below the entries looked up plus beta, and xi is drawn among the |A| - beta elements outside the table. Claims into the same table count together: a group of k claims on oracles over n variables is one run over 2^(n + s) entries, s = ceil(log2 k), with error (2^(n + s) + beta) / (|A| - beta). A statement does not determine its group, so each claim reports 2^(n + 1): since 2^s < 2k, the errors of a group’s claims add up to at least the group’s. The rest of the run is below it: 3 / |A| per sumcheck round, and 3 / |A| for each step from a layer to the next (psi, lambda and the challenges combining the trees). The bound needs a field of characteristic above the number of looked-up entries of the table.

class vfhe.piop.protocols.Lookup(field: Any, messages: OracleMessages | None = None)

Relation_Lookup -> Relation_Sum^2 x Relation_Eval^4: the lookup PIOP over a prime field of [CCCFGS26].

Round 1: the prover sends the two counter polynomials of the memory-checking lemma, and the verifier replies with the fingerprint challenges sigma_L, tau. (The paper writes the first one as sigma, the letter the range decomposition uses for its challenge-set size, so here it is zeta.)

Round 2: the prover sends the internal nodes f^(1)_a of the four grand products – one per fingerprint – together with the four products themselves, and the verifier replies with chi and the two zerocheck points rho, xi.

It then checks WSt * WSmu == RS * S, which is the multiset identity of the memory-checking lemma in fingerprinted form, and emits two sum claims: one per side of the cube, each asserting that its pair of grand products was built correctly. Each is a zerocheck over the function g of that PIOP,

sum_X eq~(point, X) * [ (f^(1)_a(X) - f_a(0,X) * f_a(1,X))
  • chi * (f^(1)_b(X) - f_b(0,X) * f_b(1,X)) ] == 0

expressed as a single VirtualOracle of degree 3. The layered f_a is itself virtual – (1 - W_n) * f^(0)_a + W_n * f^(1)_a, with f^(0)_a spelled out over the oracles the verifier already has – so the sumcheck ends on claims about mu, read_ts, final_cts and the f^(1)_a, and never on anything the verifier has to take on trust.

The driver hands the protocol every frontier Relation_Lookup claim at once. Claims into the same table t_beta on oracles with the same number of variables n form a group, and a group of k > 1 claims is one run over their concatenation: the oracles laid end to end, block i holding mu_i, over n + s variables with s = ceil(log2 k), and the blocks past k holding zeros, an entry of every table. The counters, the f^(1)_a and the products are then those of that one oracle, and in f^(0)_a the term of mu becomes sum_i sel_i * mu_i, sel_i the public eq~ table of block i over the last s variables, which keeps f_a multilinear. A group of one is the run above, unchanged.

reduces_from

alias of Relation_Lookup

parameters() → tuple

The public parameters of this protocol, in a fixed order; empty by default.

soundness_error(statement: Statement, domain: Any = None) → float

(2^(n + 1) + beta) / p for a claim on an oracle over n variables into t_beta: twice the claim’s entries, where [CCCFGS26]’s soundness theorem for its lookup PIOP counts them once.

The theorem bounds a run over 2^ell* looked-up entries into a table of 2^b* by (2^ell* + 2^b*) / p, the degree of the polynomial P(Z, Z') whose vanishing the fingerprint challenges test, over the field they are drawn from. Claims into the same table with the same number of variables count together: a group of k is one run over 2^(n + s) entries, s = ceil(log2 k), with error (2^(n + s) + beta) / p. A statement does not determine its group, so each claim reports 2^(n + 1): since 2^s < 2k, the errors of a group’s claims add up to at least the group’s.

class vfhe.piop.protocols.OutputTest

Relation_Equal(out, top) -> Eval(top, r, v), and Eval(out, r, v) unless out is public: the verifier draws r (one challenge per variable), v = out(r) is computed by the verifier when out is public and sent by the prover otherwise — the random-evaluation identity test of [Tha22, §4.6], soundness s / |A| by generalized Schwartz-Zippel [GNS23, Lem. 2]. The step that turns a sequentially composable protocol into a protocol for the relation with its head committed or public.

reduces_from

alias of Relation_Equal

soundness_error(statement: Statement, domain: Any = None) → float | None

s / |A|; the domain defaults to the output oracle’s (Oracle.domain).

class vfhe.piop.protocols.RangeDecomposition(field: Any, m: int, alphabet: int, kappa: int, ring: Any, chunks: int | None = None, messages: OracleMessages | None = None, *, max_digit_bits: int | None = None)

Relation_Range -> Relation_Lookup x Relation_Eval^(2 kappa) ([CCCFGS26]’s optimized range PIOP Pi*_range).

Round 1: the prover sends mu', the base-beta digits of the unpacked coefficients, reduced into F_p. The verifier replies with kappa points r_eta drawn from the challenge set Sigma = {0, ..., sigma-1}, a set of integers exceptional in Z_q and in F_p at once – raw coins (challenge_bits), not domain elements, because the same integers have to be read both in Z_q (to query v) and in F_p (to query mu').

Round 2: the prover sends the partial evaluations psi_eta = mu'(r'_eta, .) – binding the first m variables, an efficiency parameter – and the kappa ring values v(x_eta). The verifier replies with one spot-check point s'.

It then checks, per repetition, that the digits recompose:

sum_{delta, j} iota(psi_eta[delta, j]) * eq~(delta; r_eta^{>m})
                                      * beta^{to-int(j)}
  ==  u(x_eta, z_eta)   (mod q)

with u(x_eta, z_eta) computed from v(x_eta) by unpacked_evaluation and both sides computed as exact integers first. iota is sound there because every entry of psi_eta, as an integer, is bounded by 2^m beta sigma^m < p/2 (the parameter condition p > 2 beta (2 sigma)^m), so nothing overflows F_p.

What is left over becomes statements: that each psi_eta really is a partial evaluation of mu' (one Relation_Eval on mu' per repetition, at (r'_eta, s')), that each v(x_eta) really is an evaluation of v (one Relation_Eval on v per repetition), and that every digit is in t_beta (one Relation_Lookup).

When c does not divide log2(B), the digits are c - 1 of log2(beta) bits and a most significant one of fewer (digit_alphabets), and a Relation_Lookup(top_beta) on the restriction of mu' to the last digit (Z' all ones) follows the first: with it, the integer the digits rebuild is below beta^(c-1) * top_beta = B, not only below beta^c.

The steps that read the coefficient oracle – the digits, the queries at the integer points, the check against them and the claims they leave – are methods a subclass replaces for another form of that oracle (ResidueRangeDecomposition); the rounds, the messages of mu' and psi, the lookups and the soundness bound are shared.

Parameters: field, the prime field F_p of the digits; m, the number of variables of mu' bound in each psi_eta, an efficiency parameter (0 <= m <= ell + nu; a larger m means a smaller psi and a larger p); alphabet, the size sigma of the challenge set Sigma, a power of two at most the smallest prime of q; kappa, the number of repetitions (soundness ((ell + nu) / sigma)^kappa); ring, the R_q of the claims; chunks, the number c of digits per coefficient (digit_alphabets); messages, how mu' travels (OracleMessages). Instead of chunks, one may give max_digit_bits, the widest digit allowed in bits; each claim then gets c = digit_count(bound, max_digit_bits).

reduces_from

alias of Relation_Range

parameters() → tuple

The public parameters of this protocol, in a fixed order; empty by default.

digit_count_for(bound: int) → int

Return the number of digits c for a claim with bound bound: chunks when it was given, else digit_count(bound, max_digit_bits).

soundness_error(statement: Statement, domain: Any = None) → float

max{ ((ell+nu)/sigma)^kappa, (ell*-m)/p } ([CCCFGS26]’s theorem on Pi*_range).

The theorem’s third term is the error of the Relation_Lookup this reduces to, which that relation’s own protocol accounts for.

class vfhe.piop.protocols.ResidueRangeDecomposition(field: Any, m: int, alphabet: int, kappa: int, chunks: int | None = None, messages: OracleMessages | None = None, *, max_digit_bits: int | None = None)

Relation_ResidueRange -> Relation_Lookup x Relation_Eval^(kappa (U+1)): [CCCFGS26]’s optimized range PIOP Pi*_range with the unpacked polynomial given as an oracle of its own, in residue number system form [Gar59]: U residue oracles u_1, ..., u_U, one per prime of q, each over a field of that characteristic (F_(p_i) or an extension of it) with entries in the prime subfield. An oracle over the auxiliary ring H_q = prod_i F_(p_i^d) of [CCCFGS26] is such a tuple, which is why extension fields are allowed.

The rounds are RangeDecomposition’s: mu', the digits of the integers the residues define, then kappa points r_eta of Sigma^n, n the oracles’ variables, then the partial evaluations psi_eta and the spot point. The query at r_eta is answered on every residue oracle: the prover sends (u_1(r_eta), ..., u_U(r_eta)), each coordinate of r_eta read in the oracle’s field, and the verifier checks, for every prime:

sum_{delta, j} iota(psi_eta[delta, j]) * eq~(delta; r_eta^{>m})
                                      * beta^{to-int(j)}
  ==  u_i(r_eta)   in F_(p_i^d),

the left side the integer of RangeDecomposition’s check reduced modulo p_i. Holding at every prime, the two sides agree modulo q, which is RangeDecomposition’s check with the unpacked evaluation replaced by the oracle’s own value; an answer outside the prime subfield fails the equality. The claims left are kappa on mu', as before, and kappa U evaluation claims on the residue oracles at the integer points, in place of the kappa claims on the ring oracle.

The constructor takes RangeDecomposition’s parameters except ring: (field, m, alphabet, kappa, chunks, messages), with max_digit_bits accepted in place of chunks. The primes come from the oracles’ domains (Oracle.domain).

reduces_from

alias of Relation_ResidueRange

class vfhe.piop.protocols.SumDefStart

The composable protocol of a sum definition: the started statement’s claims L(r_i) = y_i become one Sum(sum_i alpha_i G(r_i, .), sum_i alpha_i y_i) over the summed variables, the alphas independent challenges (none for a single claim); the registered sumcheck then reduces it to one evaluation claim on that virtual oracle, and VirtualEval that claim to claims on G’s constituents, both run by the Composer inside the layer (or by the driver, for a started statement run on its own). Zero communication; soundness error (k-1)/|A| for k claims [Sor22, Lem. 11; CCCFGS25, Eqs. (19)-(20)].

reduces_from

alias of Start

soundness_error(statement: Statement, domain: Any = None) → float | None

(k - 1) / |A|; the domain defaults to the definition’s (Oracle.domain of its body).

class vfhe.piop.protocols.Sumcheck

Reduces sum_{b in {0,1}^n} f(b) == v to f(r) == v_n in n rounds.

Round i: the prover sends (g_i(0), g_i(1)) — the oracle is a single multilinear polynomial, so deg g_i = 1; the verifier checks g_i(0) + g_i(1) against the running claim, the challenge r_i is drawn from the domain’s exceptional set, and the claim becomes g_i(r_i).

The oracle may also be a virtual oracle in products form: the round message is then g_i at 0..degree, computed by the prover view’s round_evals (prover_view.py), and the final claim is an evaluation claim on the virtual oracle, which VirtualEval reduces to its constituents. After the last round the prover’s bookkeeping tables hold every constituent’s value at r [Tha13; XZZPS19, Alg. 1]; they are recorded as the prover’s witness of that claim (Prover.witnesses[claim], a dict from constituent index to value), so that the prover of the next step reads them instead of evaluating each constituent again.

reduces_from

alias of Relation_Sum

soundness_error(statement: Statement, domain: Any = None, degree: int | None = None) → float | None

degree * num_vars / |A| (piop.md §6); None if |A| is unknown. The domain defaults to the oracle’s (Oracle.domain), the degree to the oracle’s (degree attribute of a defined oracle in products form), else 1 (a multilinear table).

class vfhe.piop.protocols.SumcheckProd

Libra-style product sumcheck [XZZPS19, Alg. 3]: reduces one sum_{b in {0,1}^n} prod_j f_j(b) == v claim to k = #factors Relation_Eval claims, all at the same random point r.

Round i: each factor is linear in x_i, so the round polynomial g_i(X) = sum_b prod_j f_j(b, X) has degree k, sent as its evaluations at 0..k (values above 1 extrapolated division-free from the table halves as lo + t·(hi - lo)). The verifier checks g_i(0) + g_i(1) against the running claim and interpolates g_i(r_i) as the next claim. After the last round the prover sends the per-factor values v_j = f_j(r); the verifier checks prod_j v_j against the final claim and each (f_j, r, v_j) becomes an output Relation_Eval statement.

The native (C) path covers two native tables over a Ring — the reference Libra shape — and three over the same variables; other arities or representations use the pure-Python path. Both paths produce identical transcripts.

reduces_from

alias of Relation_SumProd

soundness_error(statement: Statement, domain: Any = None) → float | None

k * num_vars / |A| (piop.md §6); None if |A| is unknown. The domain defaults to the first factor’s (Oracle.domain).

class vfhe.piop.protocols.VirtualEval

Eval(p*, x, v) on a virtual oracle -> one Eval(p_j, h_j(x), y_j) per distinct non-public constituent query (piop.md §4).

The prover sends the constituent values y_j; the verifier evaluates the public constituents itself, checks ev(y, x) == v, and emits the claims. No challenge: each y_j is bound by its own claim and the check pins v, so the step has soundness error 0. The prover takes a y_j from the claim’s witness when the step that made the claim recorded it (Prover.witnesses[statement], constituent index to value: a sumcheck ending on the oracle does), and evaluates the constituent otherwise.

reduces_from

alias of Relation_Eval

vfhe.piop.protocols.dense_layering(root: Statement) → list[list[Statement]]

The protocol of a dense-index relation as a layered reduction: L_0 the inner relation over the root’s instance fields, its sparse index fields holding restrictions of a fresh master P, headed at the root’s head when the root is started (the Composer then starts it with the root’s claims); L_1 the realization over (P, P_dense, shape), headed at P through its index. Rule 1: P heads L_1; rule 2: L_0 reaches P through its index, L_1 mentions only P_dense beside its head. No message, no challenge, soundness error 0. Register compose(dense_layering) against the dense relation and its Start.