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.
domainis 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 — passprover/verifiersubclasses to customize them, or setfiat_shamir=Trueto 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 explicitverifier=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.pystates the rounds, the order, the soundness and the rules). Returns the sub-protocols’ results, in order.labelnames 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 indomain; when it is None, that challenge isdomain.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¶
kernelapplied once to the operands of every sub-protocol of the running AND-composition: each sub-protocol calls this with its ownoperandand receives its entry ofkernel(operands), operands in sub-protocol order.stepnames 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, asRelation_Eval’s are) has several discharges, keyed by the kind of that oracle (OracleKind) and by the protocol’sProtocol.scheme: register each commitment scheme’s evaluation protocol with no kind, andVirtualEvalforOracleKind.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
proofagainststatement, 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.
- 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
variablesthat the verifier evaluates in closed form:evaluate(coordinates)is its value at the coordinates, given in the order ofvariables, andtable()builds its denseMLEovervariables, called only when something readspolynomial(a prover that folds it as a table, or the ideal decider).The digest is that of
identityand of the variables, never of a table, soidentitymust 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
evaluatecosts: 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.domainis 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.
- 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 ofscheme– 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 committedvariables, whose order is the canonical order of evaluation points. No table: an evaluation claim on it is discharged by the evaluation protocol registered forRelation_Evalwith thatscheme(IOP.protocol_for), andqueryraises. The prover’s table is stored under the oracle inProver.witnesses, whereresolve_tablefinds 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
domainattribute).
- 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
composebuilds; see the module docstring. A subclass whose reduction depends on the IOP it runs in (its domain, say) overrideslayersinstead of passing a layering.
- class vfhe.piop.EqOracle(domain: Any, point: list, variables: list)¶
The public oracle to eq~(point, .) over
variables, the polynomial ofMLE.eq, held as its point: a query is the productprod_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 readspolynomial;pointgives the equality polynomial in factored form without it.- 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.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 byIOP.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 inProver.witnessesonce 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_forrefuses one that gets through).kindexists 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.domainis 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, itskind,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) anddigest()(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.
sendandreceiveare 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_Variableobjects 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.
- 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_digesthook).
- class vfhe.piop.Protocol¶
A reduction between products of relations (piop.md §5).
The two halves are coroutines over the same bundle of statements:
provesends the oracle messages,verifychecks round consistency, and both draw challenges viaiop.verifier.challengeand 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 = Truedeclares 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; forRelation_Eval, every claim on the oracles with onebundle_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_domainslists 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 ofstatement’s size, with the challenges drawn fromdomain’s exceptional set (exceptional_set_size),Nonewhen that set has no known size. The errors of the steps a reduction hands on to are those steps’ own.schemeis the commitment scheme, with its public parameters, whose commitments an evaluation protocol proves against;Nonefor any other protocol. The registry keys a protocol by it: a claim on aCommittedOraclegoes 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 valueselement_digesttakes;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 overridesparameters.- 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
oracleby: 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.
- class vfhe.piop.Prover(iop: IOP)¶
Computes and sends the oracles; holds the witnesses.
witnessesmaps 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] = tablefor a committed or an implicit oracle, whereresolve_tablefinds 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.
- 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).
indexis the large, reusable, preprocessable part of the instance (e.g. a circuit description); None when the relation needs none.fieldsdeclares 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_fieldsdeclares the index’s shape the same way. When it is non-empty,indexis 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,indexis 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_indexnames it, either by its position inoracles(anint) or by the name of the index field holding it (astr), andcompute_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 itshead(anImplicitOraclehandle) – for an index head the statement derives it from the index entry – andwith_startderives the companion relation and thestartmethod the Composer uses.checkignores 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
strhead_indexnames (anImplicitOraclefor a headed statement, a table otherwise);Nonefor 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);Noneotherwise. 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
statementwith the evaluation claims on its head; installed bywith_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).
- 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 throughparents(several, when a reduction consumes a batch) — the statements of one run form a DAG whose leaves the verifier decides (piop.md §5).pathnames this statement’s position in the DAG (root""; j-th child ofpisf"{p}/{j}"), identical on both sides, and namespaces the transcript.head, structural likeparentsandpath(not a field, never digested), marks the statement as headed: the oracle the relation’shead_indexnames is anImplicitOraclehandle 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 anImplicitOracle,Nonewhen it is a table, and aheadthat 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.
- 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 denseMLEor aSparseMLEofvfhe.arith, and whether the verifier holds it too. Its kind ispublicwhen 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 – andplainotherwise, the oracle of the ideal model. The table is shared, never copied: the prover folds it out of place (resolve_tablereturns 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.
writeappends an entry and fixes its position in the canonical order;readawaits 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
valueunderlabel; rewriting a label is an error.derived=Truemarks 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.rundoes it for Fiat-Shamir runs.
- state(upto: int | None = None) bytes¶
The chained hash of the first
uptowritten 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 ofdomain(the IOP’s domain by default) and write it to the transcript; later calls return the recorded value.A protocol passes
domainwhen 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, asBasefoldEval.query_positionsdoes 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, sosoundness_erroraccounting never sees it.Same contract as
challengeotherwise — 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.
- 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_kare the oracles the definition is built from: for a virtual oracleg(f_1, ..., f_k)[CBBZ23, §2.2] they are thef_i, andgis the products form below (the literature also calls thef_ithe 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, andp*holds no table of its own: a query to it atxis one query to each constituentp_jath_j(x), and the values are combined byg. Constituents are referred to by their index inconstituents.variablesare the virtual oracle’s own;maps[j]sends each variable of constituent j to its source: one ofvariables(a renaming) or a constant (a fixed coordinate of the query).termsis 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_jover the union of the constituents’ variables (identity maps).
- classmethod restriction(constituent, variables: list, fixed: dict) VirtualOracle¶
The restriction of
constituentto the slicefixed, a map from some of its variables to the constants 0 or 1, the remaining ones renamed, in order, tovariables: 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_tableresolves it to a slice of the constituent’s table;is_restrictionrecognises the form.
- is_restriction() bool¶
Whether this oracle has the form
restrictionbuilds: 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 constituentpwith the variables infixedbound to constants – elements of its domain, or integers – the remaining ones renamed, in order, tovariables, and the value scaled bycoefficient: the virtual oracle with the one constituent, one term of that coefficient and that map. A query atxis one query topat(x, fixed), scaled, which is whatprotocols.VirtualEvalreduces an evaluation claim on it to; on the prover’s sideresolve_tableresolves it to the partial evaluation ofp’s table, scaled.restrictionis the case of bits and coefficient 1;is_partial_evaluationrecognises the form.
- is_partial_evaluation() bool¶
Whether this oracle has the form
partial_evaluationbuilds (and sorestriction’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
varthrough 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
pointbecomes: 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
Rwith headuand other oraclesdep,R.Startis 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
Rwith 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 areR’s with two more fields,pointsandvalues; 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 withcompute_head, decideRwith that table in the head’s place (the residual), then oneRelation_Evalcheck per claim. The decorator also installsR.start(statement, claims), which builds the started statement from a headed statement and theRelation_Evalclaims 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 forRis a PIOP forR.Start, registered against that class.