vfhe.piop

The interactive-oracle-proof framework: an IOP runs a Protocol on a Statement of a Relation between a Prover and a Verifier, the messages on a Transcript; FS_Verifier is the Fiat-Shamir transform and Proof its output.

A statement names oracles (TableOracle, CommittedOracle, ImplicitOracle, VirtualOracle), never tables: the prover holds the tables in its witnesses. The relations are in vfhe.piop.relations and the protocols in vfhe.piop.protocols; IOP.register binds a protocol to the relation it reduces. The polynomials are vfhe.arith’s MLE and SparseMLE. Under development: the API changes between releases.

class vfhe.piop.IOP(domain=None, fiat_shamir: bool = False, prover: type[Prover] | None = None, verifier: type[Verifier] | None = None)

One protocol execution: event loop, coefficient domain, transcript, parties, and the relation -> protocol registry.

domain is the Ring or Field challenges are drawn from (its exceptional set, piop.md §6) when the oracle a protocol works on does not name its own (Oracle.domain): every protocol draws in its oracle’s domain, so one IOP may hold protocols over several. The constructor instantiates the two parties — pass prover / verifier subclasses to customize them, or set fiat_shamir=True to get the non-interactive verifier (fs.FS_Verifier: challenges derived from the transcript chain instead of sampled; the runners seed the chain with the root statement’s digest). An explicit verifier= wins over the flag. The transcript is shared by both parties: the sender writes, the receiver awaits — so rounds that do not depend on a pending message can be scheduled without blocking.

An IOP object is single-use: one run consumes its transcript. There are three runners, all consuming it:

  • run(statement) — both parties at once, the interactive execution;

  • prove(statement) -> Proof — the prover alone (Fiat-Shamir only), producing the argument string;

  • verify(statement, proof) — the verifier alone against that string.

So a non-interactive proof is produced and checked by two separate IOP objects over the same registry, which is the point: the checking side never needs the prover, its witnesses, or the oracles.

async and_composition(label: str, subprotocols: list[Coroutine], challenge_sampler: Callable[[bytes, Any], Any] | None = None) → list

Run subprotocols – coroutines, each the calling party’s side of one sub-protocol – as their AND-composition: in each round every sub-protocol sends its messages, then one challenge is drawn and every sub-protocol receives it: the conjunction case of [CDS94, Thm. 8], the AND-proof of Σ-protocols [BS23, §19.7.1], one challenge per round (and_composition.py states the rounds, the order, the soundness and the rules). Returns the sub-protocols’ results, in order.

label names the composition in the transcript: round j’s seed is the entry {label}/round{j}. challenge_sampler(seed, domain) returns the challenge a sub-protocol receives when it asks for one in domain; when it is None, that challenge is domain.random_exceptional(seed=seed).

Precondition: each sub-protocol’s statement is fixed before the composition starts – what a sub-protocol proves may not depend on messages another sub-protocol writes during the composition. The soundness error of the composition, the largest of the sub-protocols’ errors, assumes it, and nothing here checks it.

The first exception a sub-protocol raises (a verifier’s Rejection, a prover’s error) cancels the others and is raised from here.

async batched_call(step: str, operand, kernel: Callable[[list], list]) → Any

kernel applied once to the operands of every sub-protocol of the running AND-composition: each sub-protocol calls this with its own operand and receives its entry of kernel(operands), operands in sub-protocol order. step names the call, and every sub-protocol of a round must reach the same one. Writes nothing to the transcript. Outside an AND-composition, kernel([operand])[0].

register(relation_type: type[Relation], protocol: Protocol, kind: OracleKind | None = None) → Protocol

Choose the protocol that discharges statements of relation_type.

Relations without a registered protocol are terminal: the verifier decides them directly with the relation’s own check().

A relation whose statements are claims on one oracle (Relation.subject, as Relation_Eval’s are) has several discharges, keyed by the kind of that oracle (OracleKind) and by the protocol’s Protocol.scheme: register each commitment scheme’s evaluation protocol with no kind, and VirtualEval for OracleKind.virtual. A claim on a committed oracle goes to the entry of the scheme it was committed under; a claim without an entry of its own falls back to the entry of its kind, then to the default (no kind, no scheme). Claims on public oracles never reach a protocol; claims on plain oracles are refused once a scheme is registered for the relation, since a plain oracle exists only in the ideal model; claims on implicit oracles never reach the driver (the Composer consumes them).

protocol_for(statement: Statement) → Protocol | None

The protocol discharging statement, None if it is terminal.

registry_digest() → bytes

A 32-byte digest of the verifier’s configuration: the challenge domain and every registered protocol with the relation, the oracle kind and the scheme it is registered for, each by Protocol.digest (its identity and public parameters). Independent of the order of registration.

prove(statement: Statement) → Proof

Run the prover alone and return the argument string.

Fiat-Shamir only: the prover derives each challenge itself from the transcript chain, so no verifier has to be present — which is what makes the run non-interactive. (Interactively the challenges would be fresh randomness that a proof cannot carry and a verifier could not recompute, so this refuses rather than emit an unverifiable object.)

verify(statement: Statement, proof: Proof) → bool

Check proof against statement, with no prover present.

The verifier drives exactly as it would against a live prover; each message it reads is taken from the proof in order, and each challenge is re-derived from the chain over everything read so far. A proof whose messages arrive out of turn, run out, or are left over at the end is rejected, as is one whose challenges no longer fit its messages — that is the Fiat-Shamir binding doing its work.

run(statement: Statement) → bool

Run both parties concurrently on the statement; the verdict is the verifier’s output.

Each party drives its own fork of the root statement (fresh child-path counters), so both derive the same DAG paths — and the same transcript labels — independently.

class vfhe.piop.ClosedFormOracle(variables: list, evaluate: Callable[[list], Any], table: Callable[[], MLE], identity: bytes, domain: Any = None)

A public oracle to a polynomial over variables that the verifier evaluates in closed form: evaluate(coordinates) is its value at the coordinates, given in the order of variables, and table() builds its dense MLE over variables, called only when something reads polynomial (a prover that folds it as a table, or the ideal decider).

The digest is that of identity and of the variables, never of a table, so identity must determine the polynomial: two oracles whose identities are equal are taken to be the same polynomial by a Fiat-Shamir chain. Choosing bytes that do – a name of the family and every parameter of the member – is the caller’s responsibility.

The verifier’s cost on this oracle is what evaluate costs: nothing bounds it. For a succinct verifier it must run in time polylogarithmic in the table size, 2^len(variables); a protocol whose verifier may be linear can use a linear one. table() is never needed by a verifier.

domain is the ring or field of its values (Oracle.domain), given because reading it from the table would build it.

property domain: Any

The table’s ring or field; None for a table of plain integers.

property polynomial: MLE

The table, built on first use; it must be over variables.

digest() → bytes

Return the digest of the table.

For a dense table the digest is kept and reused until the oracle holds another table, or the table holds another entries object or has other variables or another basis. The kept digest assumes nobody writes into the entries object while the oracle holds it; replacing the entries object, the variables or the basis is detected.

class vfhe.piop.CommittedOracle(variables: list, commitment, scheme)

An oracle the verifier has as a commitment: commitment, produced by the commit algorithm of scheme – a polynomial commitment scheme, with its public parameters – possibly long before any IOP run and reused across runs (it rides on statements, never on the transcript), and the committed variables, whose order is the canonical order of evaluation points. No table: an evaluation claim on it is discharged by the evaluation protocol registered for Relation_Eval with that scheme (IOP.protocol_for), and query raises. The prover’s table is stored under the oracle in Prover.witnesses, where resolve_table finds it; the scheme’s own prover data (an opening) is the scheme’s business.

property domain: Any

The domain of the scheme’s committed tables, when the scheme names one (a domain attribute).

digest() → bytes

By the commitment, which binds the table, never by entries.

class vfhe.piop.Composed(layering: Callable[[Statement], list[list[Statement]]] | None, name: str = 'composed')

The protocol compose builds; see the module docstring. A subclass whose reduction depends on the IOP it runs in (its domain, say) overrides layers instead of passing a layering.

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

The layered reduction of root.

class vfhe.piop.EqOracle(domain: Any, point: list, variables: list)

The public oracle to eq~(point, .) over variables, the polynomial of MLE.eq, held as its point: a query is the product prod_i (z_i x_i + (1 - z_i)(1 - x_i)), linear in the number of variables, and the digest is that of the point. The table is built only when something reads polynomial; point gives the equality polynomial in factored form without it.

property domain: Any

The table’s ring or field; None for a table of plain integers.

property polynomial: MLE

The table of eq~(point, .), built on first use.

digest() → bytes

Return the digest of the table.

For a dense table the digest is kept and reused until the oracle holds another table, or the table holds another entries object or has other variables or another basis. The kept digest assumes nobody writes into the entries object while the oracle holds it; replacing the entries object, the variables or the basis is detected.

class vfhe.piop.FS_Verifier(iop: IOP, random: Random | None = None)

Derives both kinds of verifier randomness from the transcript chain.

Each value is H(state | tag | label): the chain state over everything written so far (Transcript.state(), seeded with the statement digest by IOP.run), a tag separating the two samplers, and the challenge’s own label (so back-to-back challenges with no message in between still differ). The derived value is then written to the transcript like any challenge, extending the chain for the next one — exactly the BCS sigma-chain [BCS16].

class vfhe.piop.ImplicitOracle(variables: list, domain: Any = None)

An implicit oracle: a handle with variables and no content of its own.

It is the head of exactly one statement of a reduction (Statement.head), and its table is whatever that statement’s relation computes from the statement’s other oracles (Relation.compute_head). On the prover’s side the table lives in Prover.witnesses once computed; the verifier has nothing of it, and never queries it: an evaluation claim on it is held by the Composer of the reduction until the layer of its head, never routed to a protocol (IOP.protocol_for refuses one that gets through). kind exists only for that refusal; digest() lets a statement carrying the handle seed a Fiat-Shamir chain in tests, the handle’s identity being its variables. domain is the domain of the table it stands for, when the statement’s builder knows it (Oracle.domain).

property domain: Any

The ring or field of the oracle’s values, in which a protocol on the oracle draws its challenges; None when the oracle does not know it, and the challenges are drawn in the IOP’s domain.

class vfhe.piop.Oracle

The contract of an oracle: variables, its kind, query(point) at a full point (the ideal decider’s one query; raises for an oracle the verifier has no table of), dependencies() (the oracles it is defined over; none for a leaf) and digest() (what a Fiat-Shamir chain absorbs when it sits in a statement). Oracles are compared by identity: claims are bundled, parked and stored (Prover.witnesses) on the object.

property domain: Any

The ring or field of the oracle’s values, in which a protocol on the oracle draws its challenges; None when the oracle does not know it, and the challenges are drawn in the IOP’s domain.

property public: bool

Whether the verifier holds the oracle’s table.

class vfhe.piop.OracleKind(*values)

What the verifier has of an oracle, which decides how an evaluation claim on it is discharged (piop.md §4):

  • public: the table itself (a wiring predicate, eq~, a public output); the claim is terminal and the verifier evaluates it.

  • committed: a commitment; the evaluation protocol of the scheme it was committed under.

  • virtual: a local definition over other oracles (virtual.py); the claim is rewritten into claims on the constituents, free of charge.

  • implicit: the head of a statement of a reduction (ImplicitOracle), a table only the prover has; the Composer consumes the claim at the layer of its head, no protocol ever does (composer.py).

  • plain: an oracle in the ideal model, which the verifier may query; admissible only while no commitment scheme is registered.

class vfhe.piop.OracleMessages

The ideal model: the table’s entries are the message.

send and receive are the two halves of one message under one transcript label. Each party gets its own oracle: the prover’s names its table, the verifier’s a table built from the entries it read, over the variables it passes (MLE_Variable objects compare by identity, so each party uses its own).

digest() → bytes

What a transcript absorbs for the way tables travel: the ideal model has no parameters.

send(prover: Prover, label: str, table: MLE) → Oracle

Write table under label and return the prover’s oracle to it.

async receive(verifier: Verifier, label: str, variables: list, field: Any) → Oracle

Read the table sent under label, a table over field with variables, and return the verifier’s oracle to it.

class vfhe.piop.Party(iop: IOP)

Common state of the two IOP roles.

class vfhe.piop.Proof(messages)

The argument string of one Fiat-Shamir run: its prover messages, in the order they were written.

“Argument string” is the term of art [CY24, §4.1; CO25, §2.1] and “NARG string” its implementation spelling [CFRG-FS, §2]; this class keeps the readable name. Deliberately not called a transcript — that word is the interactive record, prover and verifier messages both [CFRG-FS, §2].

Only the prover’s messages: the challenges are a deterministic function of what precedes them, so carrying them would store what the verifier recomputes anyway — and invite a verifier to trust them. (“The argument string pi contains a salt tau and all IP prover messages (and none of the IP verifier messages)” [CO25, §4.3].) The statement is not part of it either; public input travels separately and is bound into the chain seed.

Labels ride along so a replay can detect a message arriving out of turn. They are redundant in principle (the verifier knows what it expects next) and a byte-level encoding would drop them; keeping them here buys a clear error instead of a silent misparse.

classmethod of(transcript: Transcript) → Proof

The proof recorded by a completed prover run.

digest() → bytes

A digest of the whole proof (element_digest hook).

class vfhe.piop.Protocol

A reduction between products of relations (piop.md §5).

The two halves are coroutines over the same bundle of statements: prove sends the oracle messages, verify checks round consistency, and both draw challenges via iop.verifier.challenge and return the list of statements the bundle reduces to. Messages flow only through the IOP transcript (iop.transcript.write / await iop.transcript.read); statements are never sent — each party derives its own DAG from the common input and transcript.

batching = True declares a bundle protocol, a many-to-fewer reduction [KP23, Def. 4]: the driver hands it a bundle of statements in one invocation instead of one at a time — every frontier statement of the relation for most relations; for Relation_Eval, every claim on the oracles with one bundle_key (by default, one oracle), after every other frontier statement that could still emit a claim on such an oracle has been discharged (the parking rule, piop.md §5).

supported_domains lists the coefficient-domain types (e.g. Ring) for which native (C) kernels exist — declarative metadata, not a dispatch switch. The native/pure-Python decision is made at the data level, inside the round-message helpers (they inspect the oracle representation, e.g. mle.native_table), so protocol bodies are written once and never branch on it; both paths produce identical transcripts. An empty tuple means pure Python always.

A protocol reports its own soundness error as soundness_error(statement, domain) (piop.md §6): the error of this one step for a claim of statement’s size, with the challenges drawn from domain’s exceptional set (exceptional_set_size), None when that set has no known size. The errors of the steps a reduction hands on to are those steps’ own.

scheme is the commitment scheme, with its public parameters, whose commitments an evaluation protocol proves against; None for any other protocol. The registry keys a protocol by it: a claim on a CommittedOracle goes to the protocol of the scheme the oracle was committed under (IOP.protocol_for).

parameters() lists the public parameters the verifier’s checks depend on – a field, a repetition count, a commitment scheme – as values element_digest takes; digest() binds them with the protocol’s identity. A Fiat-Shamir chain is seeded with every registered protocol’s digest (IOP.registry_digest), so a proof is a proof under one protocol with one parameter set, which is what the transform’s soundness assumes. A protocol with a parameter the default misses overrides parameters.

parameters() → tuple

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

digest() → bytes

A 32-byte digest of the protocol’s identity (its class) and its parameters().

bundle_key(oracle) → Any

What a bundle protocol groups claims on oracle by: the driver hands it, together, the frontier claims whose oracles have equal keys, and parks a claim while another frontier statement can still produce a claim on an oracle with its key. The default is the oracle’s identity, a bundle per oracle; an evaluation protocol whose opening batches several polynomials returns its scheme instead, for one bundle per scheme. The key must be a function of public data, so that both parties form the same bundles, and it must be hashable.

reduce(statements: list[Statement], relation: Relation | type[Relation] | None = None, **fields) → Statement

One output statement of this reduction (default: reduces_to[0]).

class vfhe.piop.Prover(iop: IOP)

Computes and sends the oracles; holds the witnesses.

witnesses maps an instance handle to its private data — the witness is never a field of the statement itself, so statements stay safe to share. Keys are whatever public object the witness belongs to: a statement, an oracle (witnesses[oracle] = table for a committed or an implicit oracle, where resolve_table finds the table the prover works on), or a polynomial commitment (witnesses[commitment] = opening, the scheme’s own prover data for its evaluation protocol). Oracles and commitments survive statement forking and reduction, so they are stable keys.

async prove(statement: Statement) → list[Statement]

Follow the registered reductions; returns the terminal statements (the prover makes no decision).

exception vfhe.piop.Rejection

Raised by a protocol’s verify half when a round check fails.

class vfhe.piop.Relation(index=None)

An indexed relation R: a set of (index, instance, witness) triples.

The relation is the unit of protocol design: a protocol step is a reduction from statements of one product of relations to statements of another (piop.md §5). index is the large, reusable, preprocessable part of the instance (e.g. a circuit description); None when the relation needs none.

fields declares the instance shape: the statement field names, in canonical order — the order a Fiat-Shamir serialization will hash, so it is declared here rather than left to construction order.

index_fields declares the index’s shape the same way. When it is non-empty, index is a mapping over exactly those names, stored in the declared order; the oracles among its values (index_oracles) are oracles of every statement of the relation wherever the framework reads a statement’s oracles (statement_oracles), and its digest (index_digest) is the chain of the entries in the declared order. When it is empty, index is one opaque object, digested as it is.

check(statement) is the ideal (non-succinct) membership test for the relation’s language: it enumerates the hypercube or queries the oracle directly. It is what tests run and what the verifier is entitled to do on the fully-reduced leaf statements — not the succinct verifier.

A relation may declare that one of its oracles is determined by the others: head_index names it, either by its position in oracles (an int) or by the name of the index field holding it (a str), and compute_head(statement) computes its table from the other oracles of the statement (given concrete tables, the prover view). A statement of such a relation may then carry that oracle as its head (an ImplicitOracle handle) – for an index head the statement derives it from the index entry – and with_start derives the companion relation and the start method the Composer uses. check ignores the head: it decides the relation on whatever the statement’s oracles are.

A relation with a head must be constructible from its index alone, as type(r)(index=r.index): its start relation rebuilds it that way.

index_oracles() → tuple

The oracles among the index values, in declared order, walking tuples, lists and mappings (an entry may hold a family of tables, or a nested index); () for an opaque index.

index_head()

The index entry a str head_index names (an ImplicitOracle for a headed statement, a table otherwise); None for a relation whose head is an instance oracle or which has none.

index_digest() → bytes

The digest of a declared index: the chain of the entries in the declared order, each under its name. Cached on the instance, since an index is built once and never mutated; a table in the index is committed before the index is first digested, so that the cached digest records it by its commitment.

subject(statement: Statement) → Oracle | None

The oracle a statement of this relation is a claim about, when it is a claim on one oracle (Relation_Eval); None otherwise. The driver bundles and parks the claims with a subject per oracle, and routes them by the oracle’s kind (IOP.protocol_for); the Composer holds those whose subject is a head of its reduction.

compute_head(statement: Statement)

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

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

The started statement of a headed statement with the evaluation claims on its head; installed by with_start.

class vfhe.piop.Relation_Eval(index=None)

f(point) == value, for one oracle f: the terminal claim of the sumcheck family, and the one relation the framework itself is written against (with_start, the parking rule, the registry’s kinds).

What the verifier has of f is the oracle’s kind (piop.md §4): a table it may query, a commitment – “the commitment to f is simply the oracle pi_f” [ZCF24, §4], so a compiled claim is still this relation, R_Eval = {[(C, z, y); f] : f(z) = y and C opens to f} [ZCF24, Def. 8; BFS20], with f the witness, stored under the oracle in Prover.witnesses – a definition, or nothing but the statement that heads it.

Left terminal, the claim is decided by one oracle query (check), which needs the table: a claim on a committed oracle has no witness-free decider and must be discharged by a registered PCS evaluation protocol (e.g. vfhe.polycom.BasefoldEval).

static kind(statement: Statement) → OracleKind

The kind of the oracle this claim is about (piop.md §4).

subject(statement: Statement) → Oracle

The one oracle the claim is about: what it is bundled, parked and routed by.

class vfhe.piop.Statement(relation: Relation, parents: tuple[Statement, ...] = (), path: str = '', head: ImplicitOracle | None = None, **fields)

The claim instance ∈ L(relation); the instance fields are declared by the relation (relation.fields) and passed as keyword arguments.

Statements are verifier-shaped: every field is public, the witness lives with the prover (Prover.witnesses). Field values may hold unresolved futures (challenges not drawn yet); resolved() awaits them. Protocol steps emit the statements this one reduces to, linked through parents (several, when a reduction consumes a batch) — the statements of one run form a DAG whose leaves the verifier decides (piop.md §5). path names this statement’s position in the DAG (root ""; j-th child of p is f"{p}/{j}"), identical on both sides, and namespaces the transcript. head, structural like parents and path (not a field, never digested), marks the statement as headed: the oracle the relation’s head_index names is an ImplicitOracle handle whose table the relation computes from the others, and a Composer consumes the evaluation claims on it at this statement’s layer. None (the default) is an ordinary statement – except for a relation whose head is an index entry, where the head is derived: that entry when it is an ImplicitOracle, None when it is a table, and a head that is passed must be that entry.

property index

The relation’s index, the preprocessed part of this claim.

reduce_to(relation: Relation | type[Relation], head: ImplicitOracle | None = None, **fields) → Statement

Emit a statement this one reduces to, inheriting the oracles.

async resolved() → Statement

Await every pending future in the fields; returns self.

check() → bool

Decide the claim directly via the relation’s ideal decider.

digest() → bytes

The digest of the claim: the relation’s name, its index (a declared one through Relation.index_digest, an opaque one as it is) and the fields in their declared order, each under its name. Structural attributes (parents, path, head) are not part of it.

class vfhe.piop.TableOracle(polynomial: MLE | SparseMLE, public: bool = False)

An oracle to a table the framework holds: polynomial, a dense MLE or a SparseMLE of vfhe.arith, and whether the verifier holds it too. Its kind is public when it does – a wiring predicate, an eq~ table, a public output: an evaluation claim on it is terminal, decided by the verifier’s own evaluation – and plain otherwise, the oracle of the ideal model. The table is shared, never copied: the prover folds it out of place (resolve_table returns it as it is).

property domain: Any

The table’s ring or field; None for a table of plain integers.

digest() → bytes

Return the digest of the table.

For a dense table the digest is kept and reused until the oracle holds another table, or the table holds another entries object or has other variables or another basis. The kept digest assumes nobody writes into the entries object while the oracle holds it; replacing the entries object, the variables or the basis is detected.

class vfhe.piop.Transcript(iop: IOP | None = None)

The ordered, labeled record of the messages exchanged in one run.

write appends an entry and fixes its position in the canonical order; read awaits the entry with that label, so a receiver can be scheduled before its sender — underneath, entries are futures. Labels follow Merlin-style transcripts: they are part of the record (domain separation), not debug metadata, and a label can be written only once. The write order is the canonical order a Fiat-Shamir transformation hashes (piop.md §5); FS never touches this interface — a derandomized verifier subtype interacts with the same transcript.

write(label: str, value, derived: bool = False)

Append value under label; rewriting a label is an error.

derived=True marks a verifier-computed entry (a challenge): part of the chain like any other, but not a prover message, so it is recomputed rather than stored in the proof.

async read(label: str)

The value written under label, awaiting it if not written yet.

Reading is the verifier’s side of the wire. Against a live prover the await blocks until the message is written; against a stored proof (replay) it consumes that proof’s next message, which must be the one expected — a single forward pass, no random access.

replay(proof: Proof) → None

Feed proof’s messages to this transcript as the verifier reads them, in place of a live prover.

property fully_read: bool

Whether a replayed proof was consumed to its end.

The end-of-input check, and not a tidiness one: bytes a verifier never reads make the proof malleable — an adversary appends or alters them to obtain a second, distinct accepting proof of the same statement, costing strong simulation-extractability [CFRG-FS, §6.2; spongefish’s check_eof]. Unread messages must reject.

messages() → tuple

The prover messages, in write order — everything the verifier cannot recompute for itself. This is the proof (Proof.of).

bind(seed: bytes) → None

Set the chain’s seed — the digest of the root statement, so every derived challenge binds the claim being proven (omitting it is the “weak Fiat-Shamir” bug [DMWG23]). Must happen before the first state() computation; IOP.run does it for Fiat-Shamir runs.

state(upto: int | None = None) → bytes

The chained hash of the first upto written entries (default: all written so far): h_i = H(h_{i-1} | H(label_i) | digest(value_i)), with h_{-1} = H(seed). Recursive rather than one concatenation — the BCS chain sigma_i = H(rt_i | sigma_{i-1}) [BCS16] — so per-entry digests and chain values are cached (digests / _states): a new entry costs one link, any earlier prefix is a lookup.

class vfhe.piop.Value(iop: IOP | None = None, value=None)

An anonymous protocol value that may not be computed yet (e.g. the evaluation of an MLE at a point containing unresolved challenges).

class vfhe.piop.Variable(name: str, iop: IOP | None = None, value=None)

A named protocol variable, typically a verifier challenge r_i.

class vfhe.piop.Verifier(iop: IOP, random: Random | None = None)

Sends challenges and is restricted to oracle queries (by convention in-process; a commitment compiler can enforce it cryptographically).

random

The source of the challenges; the entropy stream when None.

async challenge(label: str, domain=None)

The challenge label: on first call, sample from the exceptional set of domain (the IOP’s domain by default) and write it to the transcript; later calls return the recorded value.

A protocol passes domain when its challenge lives in another ring or field than the IOP’s, such as a residue field of the IOP’s ring.

Either party may call this (await iop.verifier.challenge(label)) — under Fiat-Shamir the challenge is a deterministic function of the transcript so far, so both sides compute the same value; a FS verifier is a subtype overriding only the draw, and the IOP machinery stays unaware of FS. Public-coin honesty is the caller’s responsibility: draw a challenge only after writing the round message it answers, so the transcript order stays canonical.

It is awaited because, inside an AND-composition (IOP.and_composition), a challenge is shared with the other sub-protocols and waits until every one of them has written its messages for the round; outside one it returns at once.

async challenge_bits(label: str, bits: int = 256) → bytes

The bit-string challenge label: on first call, sample ceil(bits / 8) uniform bytes and write them to the transcript; later calls return the recorded value.

The second kind of verifier randomness, beside challenge, and deliberately shapeless: the verifier hands out raw coins, and how they become protocol randomness — query positions, a permutation, a subset — is the protocol’s business, expanded on its side (e.g. by a hash in counter mode, as BasefoldEval.query_positions does for its spot-check positions). It is published because derived randomness must be reproducible by the prover — once an oracle is a commitment, the prover has to learn the query positions to answer them with authentication paths. It is not a domain challenge: no exceptional-set structure, so soundness_error accounting never sees it.

Same contract as challenge otherwise — compute-if-absent, either party may call it, a Fiat-Shamir verifier derives it from the transcript instead, and inside an AND-composition it is a round shared with the other sub-protocols.

async verify(statement: Statement) → bool

Follow the registered reductions, then decide every terminal statement with its relation’s own decider — for Relation_Eval that is exactly one oracle query per claim. Never call check() on a non-terminal statement here: that decider enumerates the hypercube.

class vfhe.piop.VirtualOracle(variables: list, constituents: list, terms: list, maps=None)

p*(x) = sum_terms coeff * prod_j p_j(h_j(x)) over constituents p_j.

The constituents p_1, ..., p_k are the oracles the definition is built from: for a virtual oracle g(f_1, ..., f_k) [CBBZ23, §2.2] they are the f_i, and g is the products form below (the literature also calls the f_i the underlying or constituent polynomials). Each is an oracle in its own right – a table, a commitment, an implicit oracle or another virtual oracle – with its own variables, and p* holds no table of its own: a query to it at x is one query to each constituent p_j at h_j(x), and the values are combined by g. Constituents are referred to by their index in constituents.

variables are the virtual oracle’s own; maps[j] sends each variable of constituent j to its source: one of variables (a renaming) or a constant (a fixed coordinate of the query). terms is the products form, [(coeff, (j, ...)), ...] over constituent indices; a constituent may appear in several terms and the same oracle may be a constituent several times under different maps (W(x) and W(y)).

classmethod product(constituents: list, variables: list | None = None, coeff=1)

A single product coeff * prod_j p_j over the union of the constituents’ variables (identity maps).

classmethod restriction(constituent, variables: list, fixed: dict) → VirtualOracle

The restriction of constituent to the slice fixed, a map from some of its variables to the constants 0 or 1, the remaining ones renamed, in order, to variables: the virtual oracle with the one constituent, one term of coefficient 1 and that map – how one member of a family of tables packed into one oracle over slot variables and table variables is read, the slot being a variable map and nothing more. resolve_table resolves it to a slice of the constituent’s table; is_restriction recognises the form.

is_restriction() → bool

Whether this oracle has the form restriction builds: one constituent, one term of coefficient 1, every map source a variable of this oracle or the constant 0 or 1.

classmethod partial_evaluation(constituent: Oracle, variables: list, fixed: dict, coefficient: Any = 1) → VirtualOracle

coefficient * p(fixed, .): the constituent p with the variables in fixed bound to constants – elements of its domain, or integers – the remaining ones renamed, in order, to variables, and the value scaled by coefficient: the virtual oracle with the one constituent, one term of that coefficient and that map. A query at x is one query to p at (x, fixed), scaled, which is what protocols.VirtualEval reduces an evaluation claim on it to; on the prover’s side resolve_table resolves it to the partial evaluation of p’s table, scaled. restriction is the case of bits and coefficient 1; is_partial_evaluation recognises the form.

is_partial_evaluation() → bool

Whether this oracle has the form partial_evaluation builds (and so restriction’s): one constituent, one term over it, every map source a variable of this oracle or a constant.

classmethod linear(coeffs: list, oracles: list[VirtualOracle]) → VirtualOracle

sum_i coeffs[i] * oracles[i], one virtual oracle over the union of their variables — the constituent lists concatenated, every term scaled by its oracle’s coefficient.

property public: bool

the verifier can then evaluate it itself.

Type:

Public when every constituent is

reads(j: int, var) → bool

Whether constituent j reads the variable var through its map.

degree_in(var) → int

The degree bound in var: the most factors reading it in one term.

property degree: int

The per-variable degree bound over all variables (1 for a multilinear oracle; 0 with no variables).

property domain

The one domain of the constituents that know theirs (Oracle.domain); None when none does. Constituents over different domains raise.

query_point(j: int, point: dict | None = None) → dict

The point constituent j is queried at, for a query at point (which may leave variables free): its map with the bound sources replaced by their values.

evaluate(point: dict | list, in_place: bool = False) → VirtualOracle

Bind variables symbolically: each becomes a constant in the maps of the constituents reading it; the constituents are untouched.

constituent_values(point: dict | None = None) → list

Every constituent evaluated at its query point (the ideal decider’s queries).

combine(values: list)

ev applied to constituent values, one per constituent index.

query(point: dict) → Any

The value at a full point: one query per constituent, combined.

constant()

The value of a fully-bound virtual oracle.

claims(point: dict) → list[tuple[object, dict, list[int]]]

The constituent queries a query at point becomes: one entry (constituent, point, indices) per distinct (constituent, point) pair, public constituents excluded (the verifier evaluates those itself). Deterministic in the constituent order.

dense_constituent(j: int, table)

Constituent j as the prover reads it, a table object of its own: fixed coordinates bound (out of place), variables renamed to this oracle’s. With no fixed coordinate it shares table’s entries (table_view); a field table whose fixed coordinates are all 0 or 1 is restricted by one gather (restrict_boolean).

vfhe.piop.compose(layering: Callable[[Statement], list[list[Statement]]], name: str = 'composed') → Protocol

The protocol for a relation whose reduction is layering.

vfhe.piop.element_digest(value) → bytes

A 32-byte digest of a transcript entry or statement field: a class (a relation named in an index) by its module and qualified name; raw bytes, ints, strings and None as primitives; dicts and sequences as the chain of their parts; a protobuf message (a circuit) by its serialization; any other value by its own digest() method. Each branch is domain-separated by a tag.

vfhe.piop.exceptional_set_size(domain) → int | None

|A| for the domain’s exceptional set; None if the domain has no size.

Each arithmetic domain computes its own: the size depends on the representation, and a domain that is not an ArithParent (an int, a Fraction) has no exceptional set to report.

vfhe.piop.statement_oracles(statement: Statement) → tuple

Every oracle a statement mentions: its instance oracles followed by the index oracles of its relation. What the oracle closures (the parking rule, the Composer’s rules) and the prover view read.

vfhe.piop.with_start(cls: type[_R]) → type[_R]

Class decorator: derive the start relation of a relation with a head.

For R with head u and other oracles dep, R.Start is the relation

R_start(dep; (r_j, y_j)_j) := R(F(dep); dep) and F(dep)~(r_j) = y_j

for every j, F = R.compute_head,

that is R with its head bound to the oracle it defines, plus evaluation claims on that oracle (k >= 1 of them) at points the statement carries as data. Its statements are R’s with two more fields, points and values; the oracles, the index and the head are the same (a head named by an index field stays in the index, so a started statement of a relation with no instance fields is nothing but the index and the claims). The decider is generic: materialize the head with compute_head, decide R with that table in the head’s place (the residual), then one Relation_Eval check per claim. The decorator also installs R.start(statement, claims), which builds the started statement from a headed statement and the Relation_Eval claims on its head (the Composer calls it once per head, at its layer); the started statement is a child of the statement, with the claims as further parents. A sequentially composable PIOP for R is a PIOP for R.Start, registered against that class.